On Tue, 14 Aug 2001, Justin Nichols wrote:

> Can anyone tell me the class loader hierarchy of Tomcat 3.2.3 as it relates 
> to the CLASSPATH?
> 

Here's the hierarchy (bottom up) for Tomcat 3.2.3:
- Webapp class loader (WEB-INF/classes and WEB-INF/lib
- System class loader (i.e. contents of CLASSPATH, but see below)
- Extensions directory ($JAVA_HOME/jre/lib/ext)
- Java runtime library

There are three VERY important differences from the Tomcat 4 behavior that
was discussed earlier:

* Tomcat 3.2.3 core classes are loaded by the system class loader
  as well, along with the classes it requires (like an XML parser).
  Tomcat 4.0 core classes are loaded by a different class loader
  that is not visible to webapps, so it can use it's own XML parser
  without impacting what webapps use.

* Tomcat 3.2.3 builds a CLASSPATH for the system class loader that
  starts with what you already have on it, and then tries to add
  all JAR files in the "lib" directory.  Tomcat 4 ignores any
  CLASSPATH setting you had before (I think 3.3 does this too).

* When searching for a class, Tomcat 3.2.3 always follows the
  usual Java2 delegation pattern (ask my parent class loader if
  it has the class, and only look locally if it doesn't), while
  Tomcat 4 obeys the new statement in the Servlet 2.3 spec which
  allows the webapp class loader to look first before delegating.

The difference on the third point will show up if you have a JAR file
(say, a JDBC driver) in both the Tomcat "lib" directory *and* in
/WEB-INF/lib for your web app.  Under Tomcat 3.2.3, the version in the
Tomcat "lib" directory will always win.  In Tomcat 4, the version in the
/WEB-INF/lib directory will always win.

> Thanx
> -- 
> Justin Nichols
> [EMAIL PROTECTED]
> 

Craig


Reply via email to