Connecting to Quality Center v11 using COM4J

VBJ picture VBJ · Mar 25, 2013 · Viewed 9.3k times · Source

I am trying to connect to HP Quality Center V11 using Java code and com4j but i keep getting following error. Can someone please take a look at the error?

When I use the URL in my browser and log-in with same credentials, I was able to login. I double checked all the spelling of my domain, url, Id and password..

Error I get:

    com4j.ComException: 800403ea (Unknown error) : Failed to Login : .\invoke.cpp:517
    at com4j.Wrapper.invoke(Wrapper.java:166)
    at $Proxy5.connectProjectEx(Unknown Source)
    at com.testpack.TestClass.main(TestClass.java:23)
Caused by: com4j.ComException: 800403ea (Unknown error) : Failed to Login : .\invoke.cpp:517
    at com4j.Native.invoke(Native Method)
    at com4j.StandardComMethod.invoke(StandardComMethod.java:35)
    at com4j.Wrapper$InvocationThunk.call(Wrapper.java:340)
    at com4j.Task.invoke(Task.java:51)
    at com4j.ComThread.run0(ComThread.java:153)
    at com4j.ComThread.run(ComThread.java:134)

Code I use to connect

public static void main(String[] args) {
String url="http://XXXX/qcbin/";
    String domain="ACTIVE";
    String project="QC_2013_Projects";
    String username="XXXX";
    String password="XXXXX";
    try{
        ITDConnection itd=ClassFactory.createTDConnection();
        itd.initConnectionEx(url);
        System.out.println("Test1:"+ itd.connected());

        itd.connectProjectEx(domain,project,username,password);

        //System.out.println(itd.connected());
    }catch(Exception e){

        e.printStackTrace();
    }
}

Answer

RKH picture RKH · Mar 25, 2015

I followed these steps for getting connected to HP QC 11 from Java code using com4j on windows 7 32 bit machine

  1. Download Com4j artefacts com4j-20120426-2.zip from https://github.com/downloads/kohsuke/com4j/com4j-20120426-2.zip

  2. Unzip it. Open a command prompt and navigate to the unzipped folder. Then run following command to create Wrapper classes in a location CCCC with package structure as DDDD.

java -jar tlbimp.jar -o "C:\CCCC" -p "DDDD" "C:\Users\MYACC\AppData\Local\HP\ALM-Client\10\OTAClient.dll"

  1. Now copy the OTAClient.dll and WebClient.dll from C:\Users\MYACC\AppData\Local\HP\ALM-Client\10 and save it in Windows/System32 folder.

  2. After following the step 2, you must have a com4j-x86.dll in the location where tlbimp.jar is present. Now copy that dll to Windows/System32 folder.

  3. Now with Admin rights, register all 3 dll files using the commands 1 by 1 as follows.

regsvr32 com4j-x86.dll
regsvr32 OTAClient.dll
regsvr32 WebClient.dll

  1. Now create a Java Project in eclipse. In the src folder copy the DDDD folder created during the step 2. Add com4j.jar in class build path. Then have the following code in a java file to test the HP QC connection. Run the java file to check the result.

ITDConnection itd=ClassFactory.createTDConnection();
itd.initConnectionEx("http://10.10.10.10:8080/qcbin");
System.out.println(itd.connected());
itd.connectProjectEx("DOMAIN_NAME", "PROJECT_NAME", "HPQC_USERID", "HPQC_CREDENTIAL");
System.out.println(itd.projectConnected());

Hope this helps. :)