开发者

Why can't my applet load a native library when accessing methods by JavaScript?

I have an applet for scanning documents (using JTwain). My applet is made up of a jar I wrote, a couple of third party jars, and a dll (wrapped in the JTwain jar). I intend to load the applet, then access the applets methods using JavaScript. However I get a security exception when I do this:

java.security.AccessControlException: access denied (java.lang.RuntimePermission loadLibrary.AspriseJTwain)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkLink(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at com.asprise.util.jtwain.SourceManager.init(SourceManager.java:222)
    at com.asprise.util.jtwain.SourceManager.<init>(SourceManager.java:36)
    at com.asprise.util.jtwain.SourceManager.instance(SourceManager.java:28)
    at co.altcom.cache.scanner.CacheScan.scanToPDF(CacheScan.java:91)
    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.JSInvoke.invoke(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor3.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.LiveConnectSup开发者_StackOverflowport$PerAppletInfo.doObjectOp(Unknown Source)
    at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$LiveConnectWorker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

What's throwing me is that I can run these functions from within the applets init method just fine (no exceptions - the applet scans and saves to the computers file system). It's only when they're accessed by JavaScript that they fail. I'm guessing there's some policy I need to set, but I can't find anything about it.

Any ideas?


Wrap the code called by JS in an AccessController.doPrivileged(PrivilegedAction) (or overloaded variant).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜