我正在尝试使用 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)