You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Ronald G. Louzon" <RG...@aethersystems.com> on 2001/08/06 22:39:45 UTC

Can class load order be specified?

I have some jar files in the web-inf\lib directory under a context.  When
the
servlet for that context is loaded and the servlet class loader auto-loads
those jar files it finds in the context's lib directory, is it possible to
specify the load order of the jar files?  If not, is there a specification
which dictates what that load order should be?   It is not defined in the
servlet spec so I assume the order is provider dependent but I was wondering
if anyone knows something different.

Re: Can class load order be specified?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 6 Aug 2001, Ronald G. Louzon wrote:

> I have some jar files in the web-inf\lib directory under a context.  
> When the servlet for that context is loaded and the servlet class
> loader auto-loads those jar files it finds in the context's lib
> directory, is it possible to specify the load order of the jar files?  
> If not, is there a specification which dictates what that load order
> should be?  It is not defined in the servlet spec so I assume the
> order is provider dependent but I was wondering if anyone knows
> something different.
> 

You are correct that it is not specified in the servlet spec.  There is a
SHOULD requirement in Servlet 2.3 that JAR files should be searched in the
order they are present in the WAR file, but it is not always possible to
implement this.  For example, when Tomcat runs an app from an unpacked
directory, the original JAR file order is not known.

In servlet 2.3, however, there is one helpful MUST requirement -- the
classes from /WEB-INF/classes are to be loaded ahead of classes from a JAR
file in /WEB-INF/lib.  Therefore, if you require the ability to control
loading order, one option is to unpack the classes you want loaded first
into /WEB-INF/classes.

Craig McClanahan