Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JNI Works for application, but not when used over Tomcat...

843829Oct 13 2001 — edited Oct 15 2001
I am having problems getting JNI to work when I try to run a Servlet that invokes native calls.

I have a small, simple java program, just to test the waters, that simple calls a small shared library. It works like magic when I run the program as a simple application.

However, when I turn it into a Servlet, I get the following runtime errors:

The first time I call the Servlet:
_______________________________________________
java.lang.ExceptionInInitializerError: java.security.AccessControlException: access denied (java.lang.RuntimePermission loadLibrary.native)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
at java.security.AccessController.checkPermission(AccessController.java:399)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkLink(SecurityManager.java:837)
at java.lang.Runtime.loadLibrary0(Runtime.java:743)
at java.lang.System.loadLibrary(System.java:820)
at Native.(NativeApp.java:24)
at NativeApp.service(NativeApp.java:15)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
________________________________________________


On hitting reload (F5), I get this:
________________________________________________

java.lang.NoClassDefFoundError
at NativeApp.service(NativeApp.java:15)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
________________________________________________

Before going and farther, here is the server specs:

Linux (cobalt, basically red hat)
java 1.3
recent version of tomcat

Now, just to be sure, I removed the native call from the servlet, and ran it again...no problem this time. So I know that it has to be the native call that is causing this.

I have to say that I am still a bit new to JNI (book is in the mail form amazon still, hehe)...any ideas would really be appreciated.

I have a feeling that this may have little or nothing to do with JNI...but it seems to be related in some way.

-Zach
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2001
Added on Oct 13 2001
2 comments
227 views