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

6k views Asked by At

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

There are 1 answers

0
Lonzak On

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