tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <>
Subject Re: $CATALINA_HOME/shared/lib is Ignored, Doc Grip
Date Tue, 02 Sep 2003 06:18:26 GMT
At 08:28 PM 9/1/2003 -0500, you wrote:
>Hi all,
>I'm seeing behavior that seems contrary to the TC Documentation (seems to
>happen a lot).
>I'm running TC 5.0.9 on Win 2k, J2SDK 1.4.2_01.
>I have some JAR files (for JavaMail) in the  $CATALINA_HOME/shared/lib
>directory. I expect my web app will be able to use classes out of these JARs
>with no problem. Unfortunately, I get a NoClassDefFoundError when refering
>to classes in these JARs.

>If I move the JAR files to the $CATALINA_HOME/common/lib directory, however,
>the classes are found with no problem.

The classes are found it both cases.  It is just that in the case of 
common/lib, it is finding the one it expects to find.  Keep in mind that 
NoClassDefFoundError is *not* the same as ClassNotFoundException.  The 
former means that the class was found, but it wasn't the version it 
expected where the latter means that the class literally was not 
found.  NoClassDefFoundError might also be caused by the class being found, 
but having been loaded by a different classloader.  Not positive about that 
one, but I thought I'd throw it out there.

Basically, I'd look for another jar containing the JavaMail api somewhere 
in your classpath other than the one you put in shared/lib (make sure to 
check JAVA_HOME/jre/lib/ext and your webapp's WEB-INF/lib).  If you can't 
find another jar, then it is probably a classloader issue where the 
container requires the javamail api.    Note that server/lib can see 
common/lib (but not vice-versa), common/lib can see shared/lib (and 
vice-versa is also true in this case), but server/lib *cannot* see 
shared/lib (and vice-versa).

>According the (often innacurate) Tomcat documention, the
>$CATALINA_HOME/shared/lib should be searched.

It is, but as I stated above, there are class loader visibility issues to 
consider and JavaMail may very well have to go in common/lib in order to 
work properly in Tomcat.

>Does anyone have an explanation for why $CATALINA_HOME/shared/lib is not
>being searched?

It is, see above.

>  And just what the heck is the difference between
>$CATALINA_HOME/shared/lib vs. $CATALINA_HOME/common/lib??

Read what I said above about class loader visibility.  shared/lib is meant 
for libraries you want to make available to all of your webapps but not the 
container.  Stuff that will be also used by the container should not be 
placed here, but in common/lib which both the container and your webapps 
can see.

>The TC documentation refers to a directory, "$CATALINA_HOME/lib" and says
>that the following JARs are located there: jasper-compiler.jar,
>jasper-runtime.jar and naming-factory.jar. This is just another example of
>the shoddy TC documentation. These JAR files are all located in
>"$CATALINA_HOME/common/lib". In fact, "$CATALINA_HOME/lib" doesn't even

Supply a patch to the docs and submit it as a bug in bugzilla to the Tomcat 

A committer can take that and apply it to the CVS source.   And 
CATALINA_HOME/lib used to be the case in Tomcat4.0.x.  It changed in 
Tomcat-4.1.x and has stayed this way in Tomcat-5.0.x.  Sometimes docs get 
stale and it is up to the community (that's you) to report such things and 
help out where you can if you see something that is inadequate.


>To unsubscribe, e-mail:
>For additional commands, e-mail:

View raw message