ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a servlet application that runs fine under Tomcat, but only if I place a particular JAR file in its WEB-INF/lib directory.
If I attempt to reference this same JAR in its installed location (elsewhere on my system), or even slap it into $CATALINA_HOME/shared/lib, the servlet dies.
I've attempted specifying the JAR file by these following techniques, which I gleaned from Googling, but to no avail.
1) Edit conf/catalina.properties with something like this:
Code:
shared.loader=file:/path/to/MyFile.jar
2) I tried placing the JAR file in shared/lib, thus making the shared.loader specification this:
3) I created a setenv.sh file in $CATALINA_HOME/bin, which contained the following:
Code:
CLASSPATH=/path/to/MyFile.jar
In case 3 above, this appeared to be the most promising since the class path showed up in the output startup.sh produces, but still my servlet died.
Is there something else that I'm missing? There's not any helpful log information in catalina.out to go by. Again, from what I read while Googling, it is probably due to a ClassNotFound exception.
3) I created a setenv.sh file in $CATALINA_HOME/bin, which contained the following:
Code:
CLASSPATH=/path/to/MyFile.jar
Using your 3rd method, the file may exist, but, if is not referenced on tomcat start up, it will be ignored...
Could you try this:
1. if tomcat is running, stop it
2. Put your jar files inside the lib folder under the tomcat directory
3. restart tomcat
4. test your servlet
that directory (tomcat/lib) is where i put any shared library. Let us know if this solution works for you.
You can put your jar file on any directory in the system, but seems you're doing something wrong.
Do you use Catalina to boot up tomcat? if not, you should use some other methods.
Using your 3rd method, the file may exist, but, if is not referenced on tomcat start up, it will be ignored...
Could you try this:
1. if tomcat is running, stop it
2. Put your jar files inside the lib folder under the tomcat directory
3. restart tomcat
4. test your servlet
that directory (tomcat/lib) is where i put any shared library. Let us know if this solution works for you.
Hi Enrix,
I tried your suggestion, but still no joy.
Is there any way to get more log information from my servlet? Typically when I run it as a non-servlet, I would see a stack trace dump if it failed to start due to a ClassNotFoundException. However, in the 'catalina.out' log, all I see are messages indicating that the servlet started, but nothing indicating why it failed.
P.S. I start Tomcat using $CATALINA_HOME/bin/startup.sh
Last edited by dwhitney67; 04-10-2012 at 03:34 PM.
the default site for logs is tomcat/logs, there you will have some log files like catalina / host manager / localhost / stderr / stdout... you may check all files for stack trace.
I looked at the "localhost" log file in $CATALINA_HOME/logs, and it indeed indicated that my application was having trouble loading a JNI library (because already loaded), and if I changed a thing or two, then the log indicated that a class could not be found, etc.
I used to place my JNI library (and other project related libraries) in $CATALINA_HOME/bin, but it seems to me that they are better off in $CATALINA_HOME/lib (Thank you for that suggestion).
As for the JAR file, I've placed it in WEB-INF/lib for now. If I attempt to place it in $CATALINA_HOME/lib, I continue to get the following error:
Code:
java.lang.UnsatisfiedLinkError: Native Library /home/me/Tomcat/apache-tomcat-7.0.27/lib/libacme_jni.so already loaded in another classloader
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.