Reputation: 11
I have a two application webapp1 and webapp2. Both application use the same library zx.jar.
Now i have put the jar in two location /webapp1/ROOT/WEB-INF/lib
and /webapp2/ROOT/WEB-INF/lib
But I don't want to load jar twice. I want to use the jar /tomcat/lib
?
How can I implement this in Linux environment?
Upvotes: 0
Views: 1125
Reputation: 3794
Put your library at below location
•Tomcat 6 $CATALINA_HOME/lib
•Tomcat 5 $CATALINA_HOME/common/lib
More info Apache ClassLoader Howto.
Upvotes: 2
Reputation: 718668
With Tomcat 6, "common" JARs to be shared between multiple servlets should be placed in $CATALINA_BASE/lib
or $CATALINA_HOME/lib
. It is documented in the Apache 6 - Classloader HOW TO document.
However you need to be careful when you do this because:
lib
directories take precedence over stuff in each webapp,Upvotes: 0
Reputation: 7116
Just put your jar
in the in the tomcat lib folder ($CATALINA_HOME/lib
).
And if you are using maven as build tool, just put <scope>provided</scope>
in the dependency of the corresponding jar!
And if you are using Ant to build, just make sure that, you don't copy the jar
to the deployed application's lib folder, while building and deploying your application.
Upvotes: 1