views:

738

answers:

2

Hi

I have created a jar file to load a native library ( using System.loadlibrary() ) and configured this as a shared library within WebSphere ( v6.1 ). The server has to run with Java 2 enabled ( it's the law ... )

When I try to access the library I can see that the correct classes are being loaded from my jar file, but the attempt to load the native library gives me the following Security exception : -


Permission:

      loadLibrary.gbif : Access denied (java.lang.RuntimePermission loadLibrary.gbif)


Code:

     com.dave.nativelibrary.NativeLibraryLoader  in  {file:/hosting/apps/D03-dave-dev/lib/NativeLibraryLoader.jar}



Stack Trace:

java.security.AccessControlException: Access denied (java.lang.RuntimePermission loadLibrary.gbif)
    at java.security.AccessController.checkPermission(AccessController.java:104)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:547)
    at com.ibm.ws.security.core.SecurityManager.checkPermission(SecurityManager.java:189)
    at java.lang.SecurityManager.checkLink(SecurityManager.java:833)
    at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:917)
    at java.lang.System.loadLibrary(System.java:453)
    at com.dave.nativelibrary.NativeLibraryLoader.(NativeLibraryLoader.java:21)

--- snip ---

I'm not really sure what I'm doing - so I had a couple of attempts to put the following in to my was.policy file

permission java.lang.RuntimePermission "loadLibrary.gbif";

I tried this in both the application and jars section, but it had no beneficial effect.

Can anyone shed any light on what I need to do here?

Thanks

Dave

A: 

Instead of wrapping your native libs inside of a jar lib. Have you tried defining your native code as a shared native lib inside of websphere?

Karl
A: 

Im getting follwing exception running applet in through browser but same code is working, run as a command (appletviewer). java.security.AccessControlException: access denied (java.lang.RuntimePermission loadLibrary.C:/path/to/jRegistryKey.dll) 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.load0(Unknown Source) at java.lang.System.load(Unknown Source) at ChkSettings.init(ChkSettings.java:48) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

My "java.policy" file here:

grant{ permission java.security.AllPermission; };

grant { permission java.lang.RuntimePermission "loadLibrary.*";

permission java.lang.RuntimePermission "queuePrintJob";

permission java.net.SocketPermission "*", "connect";

permission java.io.FilePermission "<>","read";

permission java.util.PropertyPermission "*", "read";

permission java.lang.RuntimePermission "modifyThreadGroup"; };

and other default seetings their. Anything missing? Please help me on this.

Thanks, gkl