You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Les Parkin <le...@uk.lionbioscience.com> on 2001/09/19 11:22:45 UTC

Using JNI from a servlet (solution)

Hi,

There has been quite a bit of discussion on this mailing list (and others)
concerning the use of JNI from within a servlet. If you are experiencing the
"UnsatisfiedLinkError" when trying to run your servlet, check the following
(I'm assuimg a Unix environment here, but the same general principles should
apply to Windows. I'm also assuming that you're deploying everything
directly under Tomcat's directory and not using a <Context> entry for your
app):

1. Ensure your .class and .jar files are deployed in the correct place
within your Tomcat directory:

All .class files go in $TOMCAT_HOME/webapps/myapplication/WEB-INF/classes
All .jar files go in $TOMCAT_HOME/webapps/myapplication/WEB-INF/lib

2. Set your LD_LIBRARY_PATH environment variable so that it points to the
directory containing the .so file (the native code)/ The .so file can be
anywhere, the main point is that it is in your LD_LIBRARY_PATH

I had a great deal of difficulty trying to get things working until I copied
the files into the correct place as described in step 1 above. I originally
had my .jar file (that calls the native code) in a different location and
then set my CLASSPATH variable to point to it but this didn't work.



Re: Using JNI from a servlet (solution)

Posted by Jonathan Eric Miller <je...@uchicago.edu>.
There's another problem to look out for as well with regard to servlet
reloading and where you place your .jar files that use JNI. See the latest
release notes regarding that.

Jon

----- Original Message -----
From: "Les Parkin" <le...@uk.lionbioscience.com>
To: <to...@jakarta.apache.org>
Sent: Wednesday, September 19, 2001 4:22 AM
Subject: Using JNI from a servlet (solution)


> Hi,
>
> There has been quite a bit of discussion on this mailing list (and others)
> concerning the use of JNI from within a servlet. If you are experiencing
the
> "UnsatisfiedLinkError" when trying to run your servlet, check the
following
> (I'm assuimg a Unix environment here, but the same general principles
should
> apply to Windows. I'm also assuming that you're deploying everything
> directly under Tomcat's directory and not using a <Context> entry for your
> app):
>
> 1. Ensure your .class and .jar files are deployed in the correct place
> within your Tomcat directory:
>
> All .class files go in $TOMCAT_HOME/webapps/myapplication/WEB-INF/classes
> All .jar files go in $TOMCAT_HOME/webapps/myapplication/WEB-INF/lib
>
> 2. Set your LD_LIBRARY_PATH environment variable so that it points to the
> directory containing the .so file (the native code)/ The .so file can be
> anywhere, the main point is that it is in your LD_LIBRARY_PATH
>
> I had a great deal of difficulty trying to get things working until I
copied
> the files into the correct place as described in step 1 above. I
originally
> had my .jar file (that calls the native code) in a different location and
> then set my CLASSPATH variable to point to it but this didn't work.
>
>