Java COM4j无法连接到HP质量中心

Java COM4j无法连接到HP质量中心,java,hp-quality-center,com4j,Java,Hp Quality Center,Com4j,我正在尝试使用com4j生成HP Quality Center OTACLien.dll的接口 我使用下面的命令并得到这个错误 com4j版本20110322 OTAClient.dll版本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 typ

我正在尝试使用com4j生成HP Quality Center OTACLien.dll的接口

我使用下面的命令并得到这个错误

com4j版本20110322

OTAClient.dll版本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
生成了一些类,但当我尝试使用以下代码连接到QC时,我得到了一个错误

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();
        }
        }
}
错误日志

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)

OTAClient.dll是一个com组件,因此需要在系统中注册才能使用(如果使用SxS,则需要在清单中声明)

您似乎缺少OTACLIENT.DLL本身或Webclient.DLL的注册


使用regsvr32命令行实用程序注册DLL

请尝试以下代码,以建立适合我的连接:

public static void main(String[] args) {    
   //QC url
   String url = "http://101.147.167.201:8081/qcbin";
   //username for login
   String username = "username";
   //password for login
   String password = "password";
   //domain
   String domain = "domian name";
   //project
   String project = "project name";
   ITDConnection connection = ClassFactory.createTDConnection();
   connection.initConnectionEx(url);
   connection.connectProjectEx(domain, project, username, password);
}