Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Proper use of /shared/lib

 
Sam Shab
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I a nagging question about how to best make use of Tomcat's shared/lib directory that I can't seem to find a solid answer for:

Is there any chance that putting jars which are used over and over in different contexts and virtual hosts into tomcat/shared/lib will cause interaction problems across contexts? Specifically, I remember reading something a while back about Struts and Jakarta Commons libraries interacting with each other in subtle and unpleasant ways when shared in this way instead of each residing in their respective WEB-INF/lib directory.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only thing that comes to mine is static objects that you intended only to exist accross applications could exist accross multiple non-related applications. I don't know about the specific problems that could arise in the libraries you mention, but as a general rule its a bad practice for most application-related jars.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep..
Any static variables will be shared across all webapps if the class or jar files are loaded from the tomcat/lib directory.
 
Sam Shab
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes sense. It seems that the "don't put struts jars in a shared lib" advice I remember revolved around that, too. I believe the other possible gotcha is that WEB-INF/lib jars can see those in shared/lib, but not the other way around, which is the only one I could come up with when I posted.

Thanks for the answers -
 
Vlad Ilyushchenko
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/shared/lib should not be used for sharing java libraries. The name is ambiguous, i know, but this dir is to share libraries between applications and *tomcat container*. You dont want to mess with Tomcat core, do you?

To share libraries between applications only you should use /common/lib
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic