VBJ
VBJ

Reputation: 683

Connecting to Quality Center v11 using COM4J

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();
    }
}

Upvotes: 3

Views: 9507

Answers (4)

Magic Octopus Urn
Magic Octopus Urn

Reputation: 178

                    // This is a fairly important section for x64 bit machines,
                    // as a note this took me forever to figure out. Basically,
                    // if the DLL is not registered in the SysWOW64 dir then we
                    // are unable to use this as it was created when 32-bit
                    // computers were still all the rage. This is a quick little
                    // hack that registers it if it is needed to be registered.
                    // If it's already registered, this does nothing.
                    try {
                        Runtime.getRuntime()
                                .exec("C:\\windows\\SysWOW64\\regsvr32 /s lib\\OTAClient.dll")
                                .waitFor();
                        Runtime.getRuntime()
                                .exec("C:\\windows\\SysWOW64\\regsvr32 /s lib\\com4j-amd64.dll")
                                .waitFor();
                        Runtime.getRuntime()
                                .exec("C:\\windows\\SysWOW64\\regsvr32 /s lib\\com4j-x86.dll")
                                .waitFor();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        Utilities
                                .showError(
                                        new JFrame(),
                                        "OTAClient.dll, com4j-amd64.dll or com4j-x86.dll could not "
                                                + "be registered, program may or may not work on a 64-bit machine "
                                                + "without these files. You can attempt to manually register them, "
                                                + "but this rarely works.");
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

Run this before anything else in your code, it's what I used to force any machine to register them.

Upvotes: 0

pooja shree
pooja shree

Reputation: 1

I added all the 3 .dll files in c:\Windows\SysWOW64 and executed the same code.

Upvotes: 0

Rama Krishna Hati
Rama Krishna Hati

Reputation: 41

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. :)

Upvotes: 2

VBJ
VBJ

Reputation: 683

I was finally able to solve this issue. I had install HP ALM QC Client. It would install in the following path- > Your Program files->HP->HP ALM Client.

After I installed this, I was able to connect to QC.

Hope this might be useful to someone else. Thanks!

Upvotes: 1

Related Questions