wood burning stoves 2.0*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Jars in Shared\lib of tomcat" Watch "Jars in Shared\lib of tomcat" New topic
Author

Jars in Shared\lib of tomcat

Grishma Dube
Ranch Hand

Joined: Jul 01, 2003
Posts: 275
Hi,

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.

Thanks,
Grishma
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

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: 15624
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Jars in Shared\lib of tomcat
 
Similar Threads
Can we keep blzeds jars in Websphere shared libraries instead of WEB-INF/lib
Any experiences with migration from Tomcat 5 to Tomcat 6?
Help with the manager
locations of jdbc drivers and jdbc code in j2ee web application
what is common and shared directory in tomcat folder , when use each of them