tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Tomcat 4 class loader precedence order?
Date Fri, 06 Dec 2002 19:35:04 GMT
Jacob's answer is right, but I don't know if it's a complete answer to
your question.

>So, I'm curious as whether there is a determinate order that the files
>WEB-INF/lib are placed on the classpath, and also whether lib is placed
>before WEB-INF/classes. (i.e. is it alphabetical or simply whatever
>it shows up in an unsorted directory listing)

Like Jacob said, the unpacked WEB-INF/classes will be loaded and looked
for before the jars in WEB-INF/lib.  Within /WEB-INF/lib, however, you
cannot make assumptions jar loading order.  

SRV 9.4 says 
"The web application classloader must load classes from the WEB-INF/
directory first, and then from library JARs in the WEB-INF/lib

So the order of the jars is not specified.  Looking at the tomcat code,
it comes down to the Catalina DirContext implementation of
public NamingEnumeration listBindings(Name name)
                               throws NamingException
and the contract for that method doesn't mention a specific ordering.

Looking at the localhost log for tomcat on my Solaris box, it seems to
be unix alphabetical, e.g. A.jar B.jar C.jar a.jar b.jar c.jar looks at
the log on my local Solaris box.  

So in conclusion, unless I missed something, you shouldn't rely on the
class loading order of jars within the WEB-INF/lib directory.  Ideally,
you should ensure you only have one version of class on your path, or
that they are in separate repositories (e.g. WEB-INF/lib version
common/lib) where the loading order preference is clearly defined.

Yoav Shapira
Millennium ChemInformatics

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

View raw message