How can I configure Tomcat to use a shared JAR?
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 Code:
shared.loader=file:${catalina.home}/shared/lib/MyFile.jar Code:
CLASSPATH=/path/to/MyFile.jar 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. |
Hello Dwhitney67,
Quote:
Do you use Catalina to boot up tomcat? if not, you should use some other methods. Quote:
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. |
Quote:
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 |
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.
|
Enrix,
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 |
All times are GMT -5. The time now is 10:19 PM. |