Thanks Matthias. I have found out the issue. Yes, issue was Java was referring to different libvirt binary.

From: Matthias Bolte <matthias.bolte@googlemail.com>
To: D e e p a k <deepakmits@yahoo.com>
Cc: "libvirt-users@redhat.com" <libvirt-users@redhat.com>
Sent: Monday, 6 May 2013 6:07 PM
Subject: Re: [libvirt-users] hyperv connection failing with libvirt 1.0.4 virsh.

Hi,

It looks to me as virsh and your Java program are using different
versions of the libvirt binary. The one used by virsh has Hyper-V
support compiled in and the one used by your Java program doesn't.

Make sure that your Java program uses the same libvirt binary as virsh does.


2013/5/6 D e e p a k <deepakmits@yahoo.com>:
> Hi Matthias,
> Now without making any changes,through virsh hyperv connection is going
> through.
> On same setup, but when I am trying to connect using java binding to hyperv
> , it is throwing ---
>
> libvir: error : invalid argument: libvirt was built without the 'hyperv'
> driver
> exception caught:org.libvirt.LibvirtException: invalid argument: libvirt was
> built without the 'hyperv' driver
> level:VIR_ERR_ERROR
> code:VIR_ERR_INVALID_ARG
> domain:VIR_FROM_NONE
> hasConn:false
> hasDom:false
> hasNet:false
> message:invalid argument: libvirt was built without the 'hyperv' driver
> str1:invalid argument: %s
> str2:libvirt was built without the 'hyperv' driver
> str3:null
> int1:-1
> int2:-1
>
> I think libvirt is built correctly as virsh is able to connect to hyperv
> correct me if I am wrong.
> but using java binding it says "libvirt was built without the 'hyperv'
> driver".
> Can you pls. tell what I am missing when I am doing it through java binding
> or is there any setting/configuration which I am missing.
> Java code - I am using -
>
> String hypervURI = "hyperv://administrator@SBRWINPR/?transport=http";
>                ConnectAuth ca1 = new ConnectAuthDefault();
>                hypervconn = new Connect(hypervURI,ca1,0);
>                System.out.println("HYPERV:"+hypervconn.getCapabilities());
>
>
> Regards,
> Deepak
>
>
> ________________________________
> From: D e e p a k <deepakmits@yahoo.com>
> To: Matthias Bolte <matthias.bolte@googlemail.com>;
> "libvirt-users@redhat.com" <libvirt-users@redhat.com>
> Sent: Friday, 3 May 2013 9:52 AM
>
> Subject: Re: [libvirt-users] hyperv connection failing with libvirt 1.0.4
> virsh.
>
> Hi Matthias,
> Thanks for your reply.
> After checking all the required configuration. I found that firewall was not
> enabled and rules for WMI was not enabled. I made these changes.
> But now I am getting this -
>
> virsh # connect hyperv://172.168.1.111/transport=http
> Enter username for 172.168.1.111 [administrator]: administrator
> Enter administrator's password for 172.168.1.111:
> 2013-05-03 09:42:48.387+0000: 7235: info : libvirt version: 1.0.4
> 2013-05-03 09:42:48.387+0000: 7235: error : hypervDebugHandler:1444 :
> openwsman error: NULL response
> error: Failed to connect to the hypervisor
> error: internal error Transport error during enumeration: Could not connect
> (7)
>
> Any idea what is going wrong here .
>
> Regards,
> Deepak
>
> ________________________________
> From: Matthias Bolte <matthias.bolte@googlemail.com>
> To: D e e p a k <deepakmits@yahoo.com>
> Cc: "libvirt-users@redhat.com" <libvirt-users@redhat.com>
> Sent: Wednesday, 1 May 2013 4:41 PM
> Subject: Re: [libvirt-users] hyperv connection failing with libvirt 1.0.4
> virsh.
>
> 2013/4/29 D e e p a k <deepakmits@yahoo.com>
>>
>> Trying to use virsh for hyperv and getting this.
>>
>> virsh # connect hyperv://172.168.1.111:5985/?transport=http
>> Enter username for 172.168.1.111 [administrator]: administrator
>> Enter administrator's password for 172.168.1.111:
>> 2013-04-29 10:36:48.690+0000: 13991: error : hypervDebugHandler:1444 :
>> openwsman error: NULL response
>> error: Failed to connect to the hypervisor
>> error: internal error Transport error during enumeration: User, password
>> or similar was not accepted (26)
>>
>> Using libvirt 1.0.4 from source code.
>> What is going wrong in this hyperv connection ?
>
> A bit of a guess, but did you configure your Hyper-V server as described?
>
> http://libvirt.org/drvhyperv.html#auth

--
Matthias Bolte
http://photron.blogspot.com