Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

"Associators of" query

Help
Hera
2011-01-07
2013-04-03
  • Hera
    Hera
    2011-01-07

    Hello again,

       I have implemented  method that executes a query on a target machine. It works ok for "regular" select queries but if I try an "associators of" query it fails with org.jinterop.dcom.common.JIException: An internal error occurred. , cause exception being java.net.SocketTimeoutException with null detailMessage . I traced the execution up until the JDispatchImpl _class, invoke  method, and it fails in the following section of code (line 315 in my source file):
    _try{
    result = comObject.call(obj);
    }catch(JIException e)

         J-Interop doesn't support this type of queries or am I doing something wrong?

    Thanks.

     
  • Hi,
          I am not sure how an "Associators Of" query works, but if it works for a Native client , it should work for j-interop as well.

    thanks,
    best regards,
    Vikram

     
  • Joe Carter
    Joe Carter
    2013-04-03

    Hi,
    I too have a problem with an "Associators of" type query.
    For reference this command lists the files and directories under c:\Users

    Working example from PowerShell:
    Get-WmiObject -Query 'Associators of {Win32_Directory.Name="c:\\Users"}'

    Java equivalent:
    private static final String CLASS_NAME = "Associators of {Win32_Directory.Name='c:\\\\Users'}"

    Gives an error like this:
    Desc: Invalid class [
    Source: SWbemServicesEx
    Code: -2147217392
    help path: ]

    org.jinterop.dcom.impls.automation.JIAutomationException: Exception occurred. [0x80020009]
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.invoke(JIDispatchImpl.java:333)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.callMethodA(JIDispatchImpl.java:520)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.callMethodA(JIDispatchImpl.java:526)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.callMethodA(JIDispatchImpl.java:477)
    at com.avecto.joecarter.scratch.jinterop.PrintInstances.main(PrintInstances.java:57)

    The code (exception thrown from last line):
    dcomSession = init(domain, username, password);
    JIComServer comServer = new JIComServer(valueOf("WbemScripting.SWbemLocator"), hostname, dcomSession);
    IJIDispatch wbemLocator = (IJIDispatch) narrowObject(comServer.createInstance().queryInterface(IID));

    Object[] params = new Object[] { new JIString(hostname), new JIString("ROOT\CIMV2"),
    JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(),
    JIVariant.OPTIONAL_PARAM(), new Integer(0), JIVariant.OPTIONAL_PARAM() };
    JIVariant results[] = wbemLocator.callMethodA("ConnectServer", params);
    IJIDispatch wbemServices = (IJIDispatch) narrowObject(results[0].getObjectAsComObject());

    params = new Object[] { new JIString(CLASS_NAME), new Integer(0), JIVariant.OPTIONAL_PARAM() };
    JIVariant[] servicesSet = wbemServices.callMethodA("InstancesOf", params);

    Any help would be appreciated.
    Thanks
    Joe

     
  • Joe Carter
    Joe Carter
    2013-04-03

    FWIW I've worked around the problem by using "Select * from CIM_DataFile where Path =..." however it'd be nice to get Associators working.