Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 1793 invoked from network); 2 Feb 2001 19:09:02 -0000 Received: from mercury.sun.com (192.9.25.1) by h31.sny.collab.net with SMTP; 2 Feb 2001 19:09:02 -0000 Received: from centralmail1.Central.Sun.COM ([129.147.62.10]) by mercury.Sun.COM (8.9.3+Sun/8.9.3) with ESMTP id LAA29190 for ; Fri, 2 Feb 2001 11:09:06 -0800 (PST) Received: from esun1as-mm. (esun1as-mm.Central.Sun.COM [129.147.34.144]) by centralmail1.Central.Sun.COM (8.9.3+Sun/8.9.3/ENSMAIL,v2.1p1) with SMTP id MAA20798 for ; Fri, 2 Feb 2001 12:09:06 -0700 (MST) Received: from eng.sun.com by esun1as-mm. (SMI-8.6/SMI-SVR4) id MAA08878; Fri, 2 Feb 2001 12:27:19 -0700 Message-ID: <3A7B05CF.F964EA81@eng.sun.com> Date: Fri, 02 Feb 2001 11:09:04 -0800 From: "Craig R. McClanahan" X-Mailer: Mozilla 4.76 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: tomcat-dev@jakarta.apache.org Subject: Re: Servlet ClassLoader References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Marc Saegesser wrote: > > -----Original Message----- > > From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com] > >* Java asked the webapp class loader to find the > > controller servlet class > >* The webapp class loader did not find the class > > so it delegated to the shared class loader > >* The shared class loader (which reads from $CATALINA_HOME/lib > > in Tomcat 4.0 -- the corresponding loader in Tomcat 3.2 reads > > from the system classpath) and finds your class > > > > Now, when your controller servlet calls Class.forName(), it > > starts from its > > *own* class loader, and looks either there, or upwards. Of > > course, if your > > components are under WEB-INF/classes or WEB-INF/lib, they are not > > visible ... > > The Java2 class loading model is for a loader to "delegate first" to it's > parent loader. Only if the parent loader (that also delegates first to it's > parent) can't find the class will the original loader try to load it. > > The description above shows the webapp loader attempting to load the class > first and only delegating if that fails. Is this really the case? > Sorry ... I should have been more explicit here. You're right about the normal delegation model for Java2. However, the Servlet 2.3 Spec (Proposed Final Draft) gives a servlet container the option to "look before delegating" -- see Section 9.6.2. Tomcat 4.0 does this. The intention of this language is that you can have version X of a library installed as a shared resource, and version Y of the library available in WEB-INF/lib. In the 2.3 model, Y will override X. In the standard delegation model (i.e. Tomcat 3.2) you'd get the classes from X no matter what you did. Craig