Home > vSphere API > Released: vSphere Java API 2.1 Beta for vSphere 4.1

Released: vSphere Java API 2.1 Beta for vSphere 4.1

Following the vSphere 4.1 release, I am pleased to announce the release of the vSphere(VI) Java API 2.1 beta that fully supports the vSphere 4.1. The 2.1 beta has been ready for limited access for months by VMware internal teams, and partners/customers who participated vSphere 4.1 beta program.

The 2.1 beta works with VMware Infrastructure 3.0, 3.5, vSphere 4, and 4.1. It automatically detects the versions of 4 and 4.1, so you don’t need to change the way you work with the API. Besides the support of 4.1, it also includes several bug fixes since 2.0 update 1 released last December. For more info on what’s new in vSphere API 4.1, check out this blog.

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure


I plan to GA version 2.1 in about one month. Please help to give the beta a try. I need your help to report bugs for best quality of the API. You can download the API here, and file bugs here.

BTW, many thanks to those who have submitted the survey VMware does for this open source API. If you haven’t submitted yours yet, please do so quickly because the survey is closing soon. Your feedbacks are critical for the API to be supported.

Categories: vSphere API Tags:
  1. August 10th, 2010 at 07:44 | #1

    Steve, will you plan deploy your great library to Maven repositories or create your own ????
    We’re using your library for year and now project is building by Maven, so we need to deploy your library into our repo manually.

  2. August 11th, 2010 at 21:40 | #2

    Thanks Nikita,

    I will look into it and let you know when it’s done.


  3. Samir Savla
    August 13th, 2010 at 20:22 | #3

    Hi Steve,

    We have this piece of code:
    String morStr = request.getParameter(MOREF);
    if (morStr == null) {
    return null;
    String type = morStr.substring(0, morStr.indexOf(“:”));
    String value = morStr.substring(morStr.indexOf(“:”) + 1);

    ManagedObjectReference mor = new ManagedObjectReference();
    LOG.debug(“Mor type: {0}”, type);
    LOG.debug(“Mor value: {0}”, value);
    String sessionStr = “vmware_soap_session=\””;
    if(request.getParameter(SESSION_ID) == null) {
    sessionStr = sessionStr+ request.getParameter(SERVER_GUID);
    } else {
    sessionStr = sessionStr + “\””;
    LOG.debug(“morStr:{0}”, morStr);
    String serviceUrl = request.getParameter(SERVICE_URL);
    LOG.debug(“serviceUrl: {0}”, serviceUrl);
    LOG.debug(“session: {0}”, sessionStr);
    LOG.debug(“tokenId: {0}”, request.getParameter(TOKEN_ID));

    ServiceInstance si = new ServiceInstance(new URL(serviceUrl), sessionStr, true);
    LOG.debug(“Service Instance values {0} — {1}”, si.toString(), si.getServerConnection());
    ManagedEntity me = MorUtil.createExactManagedEntity(si.getServerConnection(), mor);
    LOG.debug(“Managed Entity {0}”, me.toString());
    String name = me.getName();
    String morType = me.getMOR().getType();

    LOG.debug(“Selection name: {0}”, name);
    LOG.debug(“Mor type: {0}”, morType);

    This is to connect to a vcenter server. Apparently this works fine for 4.0 but i am getting me.getName() as null when i try to connect to 4.1 vcenter server. Any ideas what could be causing this? We’ve tried to look around but couldnt find anyone with similar issues.


  4. August 13th, 2010 at 21:29 | #4

    Hi Samir,

    What version of the vijava are you using? What is the value of your MOR? Can you use MOB to verify if the MOR exists?


  5. samir savla
    August 14th, 2010 at 00:14 | #5

    Hi Steve,

    We’re using 4.0 version of vijava. When we checked the MOB we see the expected value for both the Host and the Datacenter objects. Mor type = Datacenter or HostSystem. I’m pasting the contents of the logger for your reference. As we can see the Selection Name which is the ManagedEntity name is null.


    2010-08-13 17:58:36,488 DEBUG [VMPluginServlet] Request URL = http://win-6e9ed5jke5b/vmplugin/main.run?restore=true&tokenId=d8d1a31b-8eaf-4157-a8b1-5c2cf1fd10b3&moref=HostSystem:host-17&serverGuid=F769B8B1-B4AB-4F3B-92C7-07B73B10C495&locale=en_US&serviceUrl=
    2010-08-13 17:58:36,504 DEBUG [VMPluginServlet] Mor type: HostSystem
    2010-08-13 17:58:36,504 DEBUG [VMPluginServlet] Mor value: host-17
    2010-08-13 17:58:36,504 DEBUG [VMPluginServlet] morStr:HostSystem:host-17
    2010-08-13 17:58:36,504 DEBUG [VMPluginServlet] serviceUrl:
    2010-08-13 17:58:36,504 DEBUG [VMPluginServlet] session: vmware_soap_session=”F769B8B1-B4AB-4F3B-92C7-07B73B10C495″
    2010-08-13 17:58:36,504 DEBUG [VMPluginServlet] tokenId: d8d1a31b-8eaf-4157-a8b1-5c2cf1fd10b3
    2010-08-13 17:58:36,613 DEBUG [VMPluginServlet] Service Instance values ServiceInstance:ServiceInstance @ — com.vmware.vim25.mo.ServerConnection@329d3e8
    2010-08-13 17:58:36,628 DEBUG [VMPluginServlet] Managed Entity HostSystem:host-17 @
    2010-08-13 17:58:36,644 DEBUG [VMPluginServlet] Selection name: null
    2010-08-13 17:58:36,644 DEBUG [VMPluginServlet] Mor type: HostSystem

  6. August 14th, 2010 at 00:37 | #6


    What you got for session cookie is really serverGuid not the session string. As vSphere 4.1, the session string is no longer sent by default. To fix it, check out this thread: http://communities.vmware.com/thread/278342


  7. samir savla
    August 14th, 2010 at 00:45 | #7

    Thanks Steve…I’ll try this out and let you know how this goes.

  8. yan
    August 16th, 2010 at 03:08 | #8

    Hi Jin,

    Your VIJAVA is great,but I have a problem when using it(vijava2120100715.jar) as below:

    my code is:
    ServiceInstance si = new ServiceInstance(new URL(URL), USER, PASSWORD,true);
    and always throws such error:
    Exception in thread “main” java.lang.InstantiationError: com.vmware.vim25.VimPortType
    at com.vmware.vim25.mo.ServiceInstance.(ServiceInstance.java:82)
    at com.vmware.vim25.mo.ServiceInstance.(ServiceInstance.java:69)
    I check the source and samples but still can not find the reason,any mistaken?


  9. August 16th, 2010 at 09:59 | #9

    Thanks Yan,

    It seems to me you may have included the stub generated from Apache AXIS in your classpath. Just remove it and give it another try.


  10. samir savla
    August 18th, 2010 at 12:54 | #10

    Hi Steve,

    Just wanted to update you that the fix worked and we can now discover both 4.0 and 4.1 vcenters with 4.0 vijava api’s.


  11. August 18th, 2010 at 23:05 | #11

    That is awesome! Thanks for the update Samir!


  12. yan
    August 19th, 2010 at 04:29 | #12

    Hi Steve,

    Thanks.Your are right!

  13. August 19th, 2010 at 09:08 | #13

    Thanks for the update! I am going to GA 2.1 before VMworld. Please let me know ASAP if there is any other issue so that fix can catch the release.


  14. Igor
    April 20th, 2011 at 05:18 | #14

    Hi Steve,
    we are using the latest API in our product (vijava2120100824 package). But we got the followin bug report from the client:

    “This app does not power on my esxi vms. I get restricted version error.”

    This error is returned from the ESXi server. The client’s ESXi instance ver is 4.1 and all power ops work good in VMWare vSpere client.

    Please, advise…

  15. Igor
    April 20th, 2011 at 13:42 | #15

    K, checked in the doc – the client used free license ESXi server and following the doc read only access is allowed (only) in this case.

    The issue has been closed

  16. April 20th, 2011 at 23:00 | #16

    Good to know. -Steve

  1. August 26th, 2010 at 01:20 | #1