问题描述
我正在使用 jacob
加载系统证书.当我使用 public static void main(String args[])
运行代码或说简单的 Java 程序时,它工作正常,但是当我尝试使用 Applet 运行代码时,我收到如下错误...
I'm using jacob
to load system certificate. Its working fine when I run code using public static void main(String args[])
or say simple Java program but when I try to run code using Applet I'm getting error as follow...
com.jacob.com.ComFailException: Can't co-create object
at com.jacob.com.Dispatch.createInstanceNative(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java:99)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58)
at com.digicorp.root.SystemWrapper$1.run(SystemWrapper.java:23)
at java.security.AccessController.doPrivileged(Native Method)
at com.digicorp.root.SystemWrapper.<init>(SystemWrapper.java:19)
at com.digicorp.applet.DigitalCertificateApplet.ActiveXObject(DigitalCertificateApplet.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.Trampoline.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
at sun.plugin2.liveconnect.JavaClass$MethodInfo.invoke(Unknown Source)
at sun.plugin2.liveconnect.JavaClass$MemberBundle.invoke(Unknown Source)
at sun.plugin2.liveconnect.JavaClass.invoke0(Unknown Source)
at sun.plugin2.liveconnect.JavaClass.invoke(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$DefaultInvocationDelegate.invoke(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo.doObjectOp(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$LiveConnectWorker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
我还使用了 http://netheadaches.wordpress.com/2012/04/22/jacob-cant-co-create-object/ 解决上述问题.它解决了简单的java程序,但在使用applet时相同的代码出错.
I also used http://netheadaches.wordpress.com/2012/04/22/jacob-cant-co-create-object/ to solve above problem. It solved for simple java program but while using applet same code giving error.
在将 jacob
用于小程序时,有什么我必须牢记的特定事项吗?我正在使用 jacob-1.17
Is there any specific things I have to keep in my mind while using jacob
for applet. I'm using jacob-1.17
ActiveXComponent comp=new ActiveXComponent("Encryption.LoadCertificate");
并在互联网上的某个地方找到...
and found somewhere on internet...
activeXObj = (ActiveXComponent)AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
{
return new ActiveXComponent(SystemWrapper.currentObjName);
}
});
推荐答案
您是否查看了 Jacob 附带的小程序示例?下载源和看一看.您可以在以下位置找到它:samples\com\jacob\samples\applet
.里面还有一个 readme.txt 文件.它描述了使 jacob 在小程序中运行所涉及的所有步骤.简而言之:
Did you take a look at the applet example coming with Jacob? Download the source and take a look at it. You can find it in:samples\com\jacob\samples\applet
. There is also a readme.txt file in there. It describes all the steps involved to make jacob run in an applet. In short:
- 在 jnlp 文件中指定原生库(使用 nativelib href)
- 对所有 jar 进行签名(从 Java 1.7.0_17 开始,这已成为必需)
- 设置权限/使用策略文件
这篇关于com.jacob.com.ComFailException:无法共同创建对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!