Order of class loading in a Web Application
843833Apr 15 2004 — edited Apr 15 2004Hi,
I have been trying to find out if there is a defined order in which classes contained in WEB-INF/classes
and/or WEB-INF/lib should be loaded.
There doesn't appear to be any mention of class loading order in either the J2EE 1.3 or J2EE 1.4
specifications. That does not mean that there isn't a defined class load order, it just means I haven't found one.
Typical behaviour from servers such as Tomcat (reference implementation of the Servlet Engine) show
that classes in WEB-INF/classes are loaded before classes contained in jars under WEB-INF/lib.
Because there doesn't appear to be a mandated class load order I cannot assume that the same
behaviour holds for all servers, unless someone here knows better of course.
The reason for the question is that relying on the exhibited class load order means we can patch web applications by simply putting the patch under the WEB-INF/classes directory.
If this should not be relied upon then patches will have to be applied directly to the affected jar files,
this is not a problem in itself however it is nice to be able to keep the patches out of the jars for
ease of rolling back patches without having to copy jar files all over the place.
Any insights would be welcome.
Thanks