File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Jars in Shared\lib of tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Jars in Shared\lib of tomcat" Watch "Jars in Shared\lib of tomcat" New topic

Jars in Shared\lib of tomcat

Grishma Dube
Ranch Hand

Joined: Jul 01, 2003
Posts: 275

My application is referring some 3rd party jars. If i am keeping them in TOMCAT/shared/lib then my application is working fine.
Is there any way to refer these jars without putting them in server specific location. Server is shared by multiple applications and not all the applications need these jars
and moreover i will not have access to server folders on production.

Greg Charles

Joined: Oct 01, 2001
Posts: 2968

I believe TOMCAT/shared/lib is where those jars are supposed to go. That's in contrast to TOMCAT/common/lib, which is for jars needed by the app server itself. However, you have a couple of other choices. If your multiple applications are all part of a single ear, you can put them in the ear's lib directory. If you're deploying as individual wars though, then you'd have to put them in every war's lib.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Note, however, that the shared/lib directory no longer exists in Tomcat 6 and 7. It has been replaced by a single lib directory. And Tomcat 5.x is old enough you should seriously consider upgrading.

Although I don't think it's explicitly stated, there is an implicit assumption that J2EE webapps should be self-contained - part of the "write once, run anywhere" concept. Sharing a library between apps, or worse yet, sharing memory between apps, is a questionable practice. It raises the cost of maintenance to the apps, since it's a lot easier (=cheaper) to debug issues in one app as opposed to a bunch of interacting apps. And it might make it difficult to scale the apps to some other platform such as JBoss or WebSphere. Or, for that matter, to cluster Tomcat, since each instance of a cluster resides in a separate VM with a separate memory space not sharable with other instances.

Effectively, when you put a library in the Tomcat lib (or shared/lib) directory, it becomes part of the server classpath. So all resources in that library must be thread-safe or results will be unpredictable. Which is part of the higher costs I mentioned.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Jars in Shared\lib of tomcat
It's not a secret anymore!