javahp-quality-centercom4j

COM4j unable to connect to HP Quality Center


Im am trying to generate interfaces of HP Quality Center OTACLien.dll using com4j.

I use following command and get this error.

com4j version 20110322

OTAClient.dll version 9.1

E:\dum>java -jar tlbimp.jar -o "e:\OutPutofDLL" -p ota "e:\dum\qcdll\OTAClient.dll"
Generating definitions from TDAPIOLELib
Unable to handle the type Date*
  method GetFollowUp
  interface IFollowUpManager
Unable to handle the type (IDISPATCH)*
  method get_ItemFromServer
  interface IComponentFactory

Some classes are generated but when I try to connect to QC using following code, I get Error.

import com4j.ComException;

import ota.ClassFactory;
import ota.ITDConnection;

public class OCComtest {

    public static void main(String[] args) {
        try{

        ITDConnection connection = ClassFactory.createTDConnection();
        connection.initConnectionEx("http://qc_server_IP:8080/qcbin/");
        System.out.println(connection.connected());
        }catch (ComException e) {
            e.printStackTrace();
        }
        }
}

Error Log

Exception in thread "main" com4j.ExecutionException: com4j.ComException: 80040154 CoCreateInstance failed : Class not registered : .\com4j.cpp:153
    at com4j.ComThread.execute(ComThread.java:203)
    at com4j.Task.execute(Task.java:25)
    at com4j.COM4J.createInstance(COM4J.java:97)
    at com4j.COM4J.createInstance(COM4J.java:72)
    at ota.ClassFactory.createTDConnection(ClassFactory.java:16)
    at tests.OCComtest.main(OCComtest.java:13)
Caused by: com4j.ComException: 80040154 CoCreateInstance failed : Class not registered : .\com4j.cpp:153
    at com4j.Native.createInstance(Native Method)
    at com4j.COM4J$CreateInstanceTask.call(COM4J.java:117)
    at com4j.COM4J$CreateInstanceTask.call(COM4J.java:104)
    at com4j.Task.invoke(Task.java:51)
    at com4j.ComThread.run0(ComThread.java:153)
    at com4j.ComThread.run(ComThread.java:134)

Solution

  • OTAClient.dll is a com component, as such it requires to be registered in the system to be consumed (or to be declared in a manifest if using SxS).

    It seems that you are missing registration either for OTACLIENT.DLL itself or for Webclient.dll.

    Use regsvr32 command line utility to register the dlls.