VMware {code} Community
Steve_Jin
Expert
Expert
Jump to solution

Tutorial: Get Your First VI SDK Application Running in 5 Minutes-- Beta 2 released

Just wrote a tutorial:

Steve JIN, VMware Engineering

Creator of VMware Infrastructure Java API. VI Java API 2.0 --- 15 times faster than AXIS in loading, 4+ faster in deserialization; only 1/4 of the size required by AXIS. More importantly, the freedom to redistribute your applications. (Download, Samples, DocWiki, RSS Feed)

Get Connected with Other Developers in the Community?

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
Reply
0 Kudos
38 Replies
kem5451
Enthusiast
Enthusiast
Jump to solution

You have to download jaxb-api.jar and jaxb-impl.jar. and change the line no 46 to

//import com.sun.xml.internal.bind.DatatypeConverterImpl;

import com.sun.xml.bind.DatatypeConverterImpl;//for jre1.5 support

Hope this helps you.

-Kem.

Reply
0 Kudos
soyuppy
Contributor
Contributor
Jump to solution

The key is you have to change the code. Thanks.

Reply
0 Kudos
kem5451
Enthusiast
Enthusiast
Jump to solution

Hi Steve,

Please look at the below case, am not able to get MO for specified hosts through my VC URL.

ManagedEntity[] hosts = new InventoryNavigator(rootFolder).searchManagedEntities(

new String[][] { {"HostSystem", "esx1" }, {"HostSystem", "esx2" }}, true); //where esx1 and esx2 are my host names.

java.rmi.RemoteException: VI SDK invoke exception:java.io.IOException: Server returned HTTP response code: 500 for URL: https://198.168.100.167/sdk

at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:169)

at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:118)

at com.vmware.vim25.ws.VimStub.retrieveProperties(VimStub.java:77)

at com.vmware.vim25.mo.PropertyCollector.retrieveProperties(PropertyCollector.java:78)

at com.vmware.vim25.mo.InventoryNavigator.retrieveObjectContents(InventoryNavigator.java:84)

at com.vmware.vim25.mo.InventoryNavigator.searchManagedEntities(InventoryNavigator.java:54)

But am able to get all MO by this way.

ManagedEntity[] hosts = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");

Please advice. I need to get MO for hosts on Demand not for all existing hosts.Thanks.

-Kem

Reply
0 Kudos
DataJock78
Contributor
Contributor
Jump to solution

I am getting this same thing. I followed the steps and updated to latest Java. Any ideas?

Exception in thread "main" java.rmi.RemoteException: VI SDK invoke exception:java.net.ConnectException: Connection timed out: connect

at com.vmware.vim25.ws.WSClient.invoke(_WSClient.java:169_)

at com.vmware.vim25.ws.WSClient.invoke(_WSClient.java:118_)

at com.vmware.vim25.ws.VimStub.retrieveServiceContent(_VimStub.java:1177_)

at com.vmware.vim25.mo.ServiceInstance.<init>(_ServiceInstance.java:85_)

at com.vmware.vim25.mo.ServiceInstance.<init>(_ServiceInstance.java:69_)

at com.vmware.vim25.mo.samples.HelloVM.main(_HelloVM.java:22_)

Reply
0 Kudos
DataJock78
Contributor
Contributor
Jump to solution

Reguarding the previous Post, I am not running a VC just an ESX machine. I gave it the root credentials of that ESX machine. I am running ESX3.5u3.

Thanks for any help!! This will be really cool if I can get it to work.

Reply
0 Kudos
DataJock78
Contributor
Contributor
Jump to solution

Hey guys,

Figured out what I was doing wrong. Stupid mistake, fat fingered the IP address. Sorry for the bother works great!!

Reply
0 Kudos
kem5451
Enthusiast
Enthusiast
Jump to solution

Steve,

Any clue on my previous post. Am not able to get MOs for multiple ESX hosts given through VC.

Please advice. Thanks.

-Kem

Reply
0 Kudos
Steve_Jin
Expert
Expert
Jump to solution

Hi Kem,

Sorry for being late to get back to you -- I was in EclipseCon these days.

I reposted your question and answered it on the project home on the sourceforge.net:

For all the folks,

Please post VI Java API related questions to the sourceforge forum in the future:

Thanks!

-Steve

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
Reply
0 Kudos
kem5451
Enthusiast
Enthusiast
Jump to solution

Hi Steve,

One quick question.

In VI JAVA - How can we terminate the already opened user session through our API. This has been provided in VI SDK.

Ex -

TerminateUserSession t = new TerminateUserSession(up, username, password);// in VI SDK

t.doTheWork(); //will terminate the opened session.

Do we have like this in VI JAVA API?

Thanks.

-Kem

Reply
0 Kudos
kem5451
Enthusiast
Enthusiast
Jump to solution

Steve,

Please ignore my previous post.

Am just trying to terminate the orphan user sessions which are in the server using VI JAVA API.

Please help me if you can. Thanks.

-Kem

Reply
0 Kudos
kem5451
Enthusiast
Enthusiast
Jump to solution

Got it.

-Kem.

Reply
0 Kudos
rickyelqasem
Enthusiast
Enthusiast
Jump to solution

Steve cannot wait for your book - hopefully has some C# examples?

Ricky El-Qasem

VCI/VCP - MCSE - RHCT

Ricky El-Qasem VCI/VCP - MCSE - RHCT
Reply
0 Kudos
Muthuganesh
Contributor
Contributor
Jump to solution

Steve,

The jaxb jars are not distributable ( CDDL license ) , you cannot bundle it for commercial products.

can you please make it compatible for jre 1.5 or suggest changes

this is important for us to decide.

-Ganesh

Reply
0 Kudos
Muthuganesh
Contributor
Contributor
Jump to solution

Steve,

The jaxb jars are not distributable ( CDDL license ) , you cannot bundle it for commercial products.

can you please make it compatible for jre 1.5 or suggest changes

this is important for us to decide.

Reply
0 Kudos
Muthuganesh
Contributor
Contributor
Jump to solution

Steve,

The jaxb jars are not distributable ( CDDL license ) , you cannot bundle it for commercial products.

can you please make it compatible for jre 1.5 or suggest changes

this is important for us to decide.

-Ganesh

Reply
0 Kudos
pratap533
Contributor
Contributor
Jump to solution

Hi steve,

                   I am very grateful for your work...i have used your programs for student project.

i have simple requirement for ignorecertificate to be false.

Please if there is a way could you tell how to do it

with this my project will be over.

Thank you..

Reply
0 Kudos
pratap533
Contributor
Contributor
Jump to solution

Hi Steve,

In hello world program

ServiceInstance si = new ServiceInstance( new URL("https://servername/sdk"), "root", "password", true);

True parameter indicates that ignore certificate to be true.

i want ignore certificate to be false. so that i can give some certificate.

How to acheive this task.

Please suggest me is it possible to make the ignorecertificate parameter to false..

In such case how to acheive this..

Thanks in advance.

Reply
0 Kudos
Steve_Jin
Expert
Expert
Jump to solution

It's more than a short description, but the good thing is that it's not different from other Java programs using SSL certificate. At high level, you will need the server certificate into your keystore and include the keystore in the JVM parameter.

Check out the keytool command for more details.

Steve

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
Reply
0 Kudos
pratap533
Contributor
Contributor
Jump to solution

i have some idea on keytool and i created the keystore.jks using the following command.

c:/java/jre/bin>keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048

it creates the keystore.jks in the bin folder.

i have to understand how to refer this keystore.jks in the java program.(i am having less knowledge on this...sorry)

what is meant when you said i need the server certificate into my keystore..

i just have to know how my program can make use of the keystore  so that the certificate is identified by esxi server.

Thanks for your reply..

Reply
0 Kudos