0 Replies Latest reply on Jun 25, 2010 8:22 AM by 843811

    Of Signed Applets & JNI & ClassLoaders

      Hi everyone,

      I have a problem regarding a signed applet and trying to load a dll (JNI) using a Custom classloader. I'll try to be concise:

      -- I have my application deployed as JAVA Applet.
      -- This applet needs local resources and to allow access to them I signed the applet so the user must accept its excution (not trusted CA)
      -- The applet needs to load a dll using System.loadLibrary() and it works just fine. ( The Class with JNI attachments and native methods is loaded by the default ClassLoader).

      But the problem is:
      -- I need to load the JNI Class (and the dll library) using a CustomClassLoader. I ' ve already done that but then I'm getting now the following exception:

      java.security.AccessControlException: access denied (java.lang.RuntimePermission loadLibrary.libeyePFoundationWrapper)
           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 javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
           at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

      It is strange because everything is the same except that i'm using a different ClassLoader. I've checked the class is correctly read and even instantiated but the call to System.loadLibrary() fails.

      Here is what I've done/tried/checked after searching through google:

      -- I've set all permissions in the java.policy file
      -- I've found the applets must be signed to access local resources (The applet was already signed)
      -- The JNI library is found by the JVM (With the default class loader works)
      -- The JNI library works fine (with the default class loader works)
      -- Happens with firefox and IE
      -- And finally: Everything works fine inside the appletviewer!!!!

      I don't know what else to do. Maybe the security manager does not allow dll loading using a different ClassLoader.

      Code snippets can be provided if it'll help solve the mistery.