Hyper-V WMI test works for Windows2012 but fail on Windows 2012R2

Kenny
2014-04-11
2014-04-11
  • Kenny

    Kenny - 2014-04-11

    I tried to get some basic information from Hyper-V WMI provider. The program works well to get requested information from a Windows 2012 server, but failed from a Windows 2012 R2 server. The exception is from "JIVariant Count = wbemObjectSet_dispatch.get("Count");":
    org.jinterop.dcom.impls.automation.JIAutomationException: Exception occurred. [0x80020009]
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.invoke(JIDispatchImpl.java:331)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.get(JIDispatchImpl.java:416)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.get(JIDispatchImpl.java:433)
    at org.jinterop.dcom.test.HyperVPerf.performOp(HyperVPerf.java:71)
    at org.jinterop.dcom.test.HyperVPerf.main(HyperVPerf.java:109)
    Caused by: org.jinterop.dcom.common.JIRuntimeException: Exception occurred. [0x80020009]
    at org.jinterop.dcom.core.JICallBuilder.readResult(JICallBuilder.java:1095)
    at org.jinterop.dcom.core.JICallBuilder.read(JICallBuilder.java:969)
    at ndr.NdrObject.decode(NdrObject.java:36)
    at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:137)
    at rpc.Stub.call(Stub.java:113)
    at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:990)
    at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:945)
    at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:271)
    at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:156)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.invoke(JIDispatchImpl.java:313)
    ... 4 more

    My sample code is(almost copied from MSWMI.java in test package):

    "

    package org.jinterop.dcom.test;

    import java.net.UnknownHostException;
    import java.util.logging.Level;

    import org.jinterop.dcom.common.JIException;
    import org.jinterop.dcom.common.JISystem;
    import org.jinterop.dcom.core.IJIComObject;
    import org.jinterop.dcom.core.JIArray;
    import org.jinterop.dcom.core.JIComServer;
    import org.jinterop.dcom.core.JIProgId;
    import org.jinterop.dcom.core.JISession;
    import org.jinterop.dcom.core.JIString;
    import org.jinterop.dcom.core.JIVariant;
    import org.jinterop.dcom.impls.JIObjectFactory;
    import org.jinterop.dcom.impls.automation.IJIDispatch;
    import org.jinterop.dcom.impls.automation.IJIEnumVariant;

    / WMI example showing how to use a new logger implementation.

    * @since 1.23

    */
    public class HyperVPerf {

    private JIComServer comStub = null;
    private IJIComObject comObject = null;
    private IJIDispatch dispatch = null;
    private String address = null;
    private JISession session = null;
    public HyperVPerf(String address, String[] args) throws JIException, UnknownHostException
    {
        this.address = address;
        session = JISession.createSession(args[1],args[2],args[3]);
        comStub = new JIComServer(JIProgId.valueOf("wbemScripting.SwbemLocator"),address,session);
        IJIComObject unknown = comStub.createInstance();
        comObject = (IJIComObject)unknown.queryInterface("76A6415B-CB41-11d1-8B02-00600806D9B6");//ISWbemLocator
        dispatch = (IJIDispatch)JIObjectFactory.narrowObject(comObject.queryInterface(IJIDispatch.IID));
    }
    
    public void performOp() throws JIException, InterruptedException
    {
        JIVariant results[] = dispatch.callMethodA("ConnectServer",new Object[]{
                new JIString(address),
                new JIString("root\\virtualization"),
                JIVariant.OPTIONAL_PARAM(),
                JIVariant.OPTIONAL_PARAM(),
                JIVariant.OPTIONAL_PARAM(),
                JIVariant.OPTIONAL_PARAM(),
                new Integer(0),
                JIVariant.OPTIONAL_PARAM()
                }
                );
    
        IJIDispatch wbemServices_dispatch = (IJIDispatch)JIObjectFactory.narrowObject((results[0]).getObjectAsComObject().queryInterface(IJIDispatch.IID));
        results = wbemServices_dispatch.callMethodA("ExecQuery", new Object[]{
                                                            new JIString("select * from Msvm_VirtualSwitch"), 
                                                            JIVariant.OPTIONAL_PARAM(), 
                                                            JIVariant.OPTIONAL_PARAM(),
                                                            }
                                                    );
        IJIDispatch wbemObjectSet_dispatch = (IJIDispatch)JIObjectFactory.narrowObject((results[0]).getObjectAsComObject().queryInterface(IJIDispatch.IID));
        JIVariant variant = wbemObjectSet_dispatch.get("_NewEnum");
        IJIComObject object2 = variant.getObjectAsComObject();
    
        IJIEnumVariant enumVARIANT = (IJIEnumVariant)JIObjectFactory.narrowObject(object2.queryInterface(IJIEnumVariant.IID));
    
        JIVariant Count = wbemObjectSet_dispatch.get("Count");
        int count = Count.getObjectAsInt();
        System.out.println("Count: " + count);
        for (int i = 0; i < count; i++)
        {
            Object[] values = enumVARIANT.next(1);
            JIArray array = (JIArray)values[0];
            Object[] arrayObj = (Object[])array.getArrayInstance();
            for (int j = 0; j < arrayObj.length; j++)
            {
                IJIDispatch wbemObject_dispatch = (IJIDispatch)JIObjectFactory.narrowObject(((JIVariant)arrayObj[j]).getObjectAsComObject());
                JIVariant variant2 = (JIVariant)(wbemObject_dispatch.callMethodA("GetObjectText_",new Object[]{new Integer(1)}))[0];
                System.out.println(variant2.getObjectAsString().getString());
                System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            }
        }
    
    }
    
    private void killme() throws JIException
    {
        JISession.destroySession(session);
    }
    
    public static void main(String[] args) {
    
        try {
                if (args.length < 4)
                {
                    System.out.println("Please provide address domain username password");
                    return;
                }
    
                JISystem.setInBuiltLogHandler(false);
                JISystem.getLogger().setLevel(Level.FINEST);
                JISystem.setAutoRegisteration(true);
                HyperVPerf test = new HyperVPerf(args[0],args);
                test.performOp();
                test.killme();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
    

    }

    "

    Any suggestions?

     
    Last edit: Kenny 2014-04-11
    • Vikram Roopchand

      Please have a look at the detailed information from the exception. There
      are methods on jiautomationexception for this (getexcepinfo, I think) ...

      Best regards,
      Vikram
      On Apr 11, 2014 11:41 AM, "Kenny" kkpapa@users.sf.net wrote:

      I tried to get some basic information from Hyper-V WMI provider. The
      program works well to get requested information from a Windows 2012 server,
      but failed from a Windows 2012 R2 server. The exception is:
      org.jinterop.dcom.impls.automation.JIAutomationException: Exception
      occurred. [0x80020009]
      at
      org.jinterop.dcom.impls.automation.JIDispatchImpl.invoke(JIDispatchImpl.java:331)
      at
      org.jinterop.dcom.impls.automation.JIDispatchImpl.get(JIDispatchImpl.java:416)
      at
      org.jinterop.dcom.impls.automation.JIDispatchImpl.get(JIDispatchImpl.java:433)
      at org.jinterop.dcom.test.HyperVPerf.performOp(HyperVPerf.java:71)
      at org.jinterop.dcom.test.HyperVPerf.main(HyperVPerf.java:109)
      Caused by: org.jinterop.dcom.common.JIRuntimeException: Exception
      occurred. [0x80020009]
      at org.jinterop.dcom.core.JICallBuilder.readResult(JICallBuilder.java:1095)
      at org.jinterop.dcom.core.JICallBuilder.read(JICallBuilder.java:969)
      at ndr.NdrObject.decode(NdrObject.java:36)
      at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:137)
      at rpc.Stub.call(Stub.java:113)
      at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:990)
      at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:945)
      at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:271)
      at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:156)
      at
      org.jinterop.dcom.impls.automation.JIDispatchImpl.invoke(JIDispatchImpl.java:313)
      ... 4 more

      My sample code is(almost copied from MSWMI.java in test package):
      package org.jinterop.dcom.test;

      import java.net.UnknownHostException;
      import java.util.logging.Level;

      import org.jinterop.dcom.common.JIException;
      import org.jinterop.dcom.common.JISystem;
      import org.jinterop.dcom.core.IJIComObject;
      import org.jinterop.dcom.core.JIArray;
      import org.jinterop.dcom.core.JIComServer;
      import org.jinterop.dcom.core.JIProgId;
      import org.jinterop.dcom.core.JISession;
      import org.jinterop.dcom.core.JIString;
      import org.jinterop.dcom.core.JIVariant;
      import org.jinterop.dcom.impls.JIObjectFactory;
      import org.jinterop.dcom.impls.automation.IJIDispatch;
      import org.jinterop.dcom.impls.automation.IJIEnumVariant;

      /
      WMI example showing how to use a new logger implementation.
      * @since 1.23

      */
      public class HyperVPerf {

      private JIComServer comStub = null;private IJIComObject comObject = null;private IJIDispatch dispatch = null;private String address = null;private JISession session = null;public HyperVPerf(String address, String[] args) throws JIException, UnknownHostException{
      this.address = address;
      session = JISession.createSession(args[1],args[2],args[3]);
      comStub = new JIComServer(JIProgId.valueOf("wbemScripting.SwbemLocator"),address,session);
      IJIComObject unknown = comStub.createInstance();
      comObject = (IJIComObject)unknown.queryInterface("76A6415B-CB41-11d1-8B02-00600806D9B6");//ISWbemLocator
      dispatch = (IJIDispatch)JIObjectFactory.narrowObject(comObject.queryInterface(IJIDispatch.IID));}
      public void performOp() throws JIException, InterruptedException{
      JIVariant results[] = dispatch.callMethodA("ConnectServer",new Object[]{
      new JIString(address),
      new JIString("root\virtualization"),
      JIVariant.OPTIONAL_PARAM(),
      JIVariant.OPTIONAL_PARAM(),
      JIVariant.OPTIONAL_PARAM(),
      JIVariant.OPTIONAL_PARAM(),
      new Integer(0),
      JIVariant.OPTIONAL_PARAM()
      }
      );

      IJIDispatch wbemServices_dispatch = (IJIDispatch)JIObjectFactory.narrowObject((results[0]).getObjectAsComObject().queryInterface(IJIDispatch.IID));
      results = wbemServices_dispatch.callMethodA("ExecQuery", new Object[]{
                                                          new JIString("select * from Msvm_VirtualSwitch"),
                                                          JIVariant.OPTIONAL_PARAM(),
                                                          JIVariant.OPTIONAL_PARAM(),
                                                          }
                                                  );
      IJIDispatch wbemObjectSet_dispatch = (IJIDispatch)JIObjectFactory.narrowObject((results[0]).getObjectAsComObject().queryInterface(IJIDispatch.IID));
      JIVariant variant = wbemObjectSet_dispatch.get("_NewEnum");
      IJIComObject object2 = variant.getObjectAsComObject();
      
      IJIEnumVariant enumVARIANT = (IJIEnumVariant)JIObjectFactory.narrowObject(object2.queryInterface(IJIEnumVariant.IID));
      
      JIVariant Count = wbemObjectSet_dispatch.get("Count");
      int count = Count.getObjectAsInt();
      System.out.println("Count: " + count);
      for (int i = 0; i < count; i++)
      {
          Object[] values = enumVARIANT.next(1);
          JIArray array = (JIArray)values[0];
          Object[] arrayObj = (Object[])array.getArrayInstance();
          for (int j = 0; j < arrayObj.length; j++)
          {
              IJIDispatch wbemObject_dispatch = (IJIDispatch)JIObjectFactory.narrowObject(((JIVariant)arrayObj[j]).getObjectAsComObject());
              JIVariant variant2 = (JIVariant)(wbemObject_dispatch.callMethodA("GetObjectText_",new Object[]{new Integer(1)}))[0];
              System.out.println(variant2.getObjectAsString().getString());
              System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
          }
      }
      

      }
      private void killme() throws JIException{
      JISession.destroySession(session);}
      public static void main(String[] args) {

      try {
              if (args.length < 4)
              {
                  System.out.println("Please provide address domain username password");
                  return;
              }
      
              JISystem.setInBuiltLogHandler(false);
              JISystem.getLogger().setLevel(Level.FINEST);
              JISystem.setAutoRegisteration(true);
              HyperVPerf test = new HyperVPerf(args[0],args);
              test.performOp();
              test.killme();
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }}
      

      }

      Any suggestions?

      Hyper-V WMI test works for Windows2012 but fail on Windows 2012R2https://sourceforge.net/p/j-interop/discussion/600729/thread/d7a1687e/?limit=50#f4a9

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/j-interop/discussion/600729/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      • Kenny

        Kenny - 2014-04-11

        From e.getExcepInfo():

        Exception info: org.jinterop.dcom.impls.automation.JIExcepInfo@48067064

        How can I get more detail information of this exception?

         

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks