I am new to vsphere API and trying to follow samples here.
I have added following jars in my classpath:
1.yavijava-6.0.05.jar and dependent jars
2.vSphere Client SDK jars (vsphere-client-sdk-126.96.36.19900-15863815\html-client-sdk\libs)
when I try to create serviceInstance object,
ServiceInstance si = new ServiceInstance(new URL("https://<VC ip>/sdk/vimService"), "<username>", "<password>",
I get following error:
Exception in thread "main" java.lang.NoSuchMethodError: 'void com.vmware.vim25.ManagedObjectReference.set_value(java.lang.String)' at com.vmware.vim25.mo.ServiceInstance.(ServiceInstance.java:58)
Earlier I tried using vijava jars and I got following error
java.lang.RuntimeException: java.rmi.RemoteException: VI SDK invoke exception:org.dom4j.DocumentException: null Nested exception: null
Moderator: Moved to vSphere Client SDK Discussions
If you are more interested in the core vCenter API please use the vSphere Web Services SDK.
In terms of the actual library to use VMware supports only vim25.jar (official vSphere Web Service SDK deliverable). You can find one in the vSphere Client SDK jars (html-client-sdk\libs).
javijava.jar and vijava.jar are actually 3rd party libraries packaging the same APIs but not released by VMware. As such their backward compatibility with new versions of vSphere does not come out of the box.
Also keep in mind you should use only one of these libraries at a time as they might clash runtime.
Obviously, my recommendation is to use only vim25.jar.
Hope this helps.
With yavijava-6.0.05.jar we can still connect to VC7.0 +,
Try this code,
ServiceInstance si = new ServiceInstance(new URL("https://" + vcIPaddress + ":443/sdk"), userName, passwd,
System.out.println(si.getAboutInfo().getFullName()); // VMware vCenter Server 7.0.2 build-17694817
Also set below two VM arguments ,i.e,
The error occurs, because vijava and your chosen fork yavijava are trying this:
The problem is the following:
That code tries to use the method ManagedObjectReference.set_value(String) and the jar comes with that class included.
If you added the default vim25.jar from VMware it also includes this class with the exact same name and package path.
Now some part has to decide which of these two classes its gonna use when that method gets called, but they're not identical. The vim25-version instead of set_value(String) has the method setValue(String). So if whatever part decides to use the vim25-version, the method set_value(String) is not existing and throws your error.
So in short: make sure that you dont use vijava/yavijava and vim25 in the same project.
I want to know where is latest java APIs with 7.0.2 version of APIs, to work with Remote Plug-ins with the vSphere Client SDK (7.0 Update 2). I am not able find java samples or API documentation/ javadocs
We can see java script APIs but not java APIs. Am I missing something?
Remote plugins are serving the UI resources directly from the vendor backend appliance.
If it runs Java you can use the vSphere Web Services SDK 7.0.2 (vim25) which is available here: https://code.vmware.com/web/sdk/7.0/vsphere-management
Note these are backend APIs, hence you don't see this in the Remote plugins guide which is covering vSphere Client SDK.
That said, the vSphere Client SDK contains a remote-plugin-sample which demonstrates the usage of vim25 Java APIs.
Please check that for code references.