Question

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

Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top