com.jacob.com.ComFailException: Can't co-create object

三世轮回 提交于 2019-12-11 18:37:26

问题


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)

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.

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

回答1:


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:

  1. specify the native lib in the jnlp file (with nativelib href)
  2. sign all jars (since java 1.7.0_17 this has become mandatory)
  3. set the permissions / use a policy file


来源:https://stackoverflow.com/questions/18446464/com-jacob-com-comfailexception-cant-co-create-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!