tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: jar's still not picked up in WEB-INF/lib
Date Mon, 09 Oct 2000 22:18:43 GMT

I wanted to thank you for responding with your detailed test cases on
where classes can see each other with Tomcat 4.0-m1.  I cannot seem to
find your original message in my mail reader (even though I printed it
last night), but wanted to respond.

You reported that the (G) and (H) scenarios failed.  To review, those
two scenarios were as follows:





It would be my contention that these two cases SHOULD fail -- and the
reasoning goes like this:

* In a Java class, when you say something like
    C2 myobject = new C2(...);
  the "new" operator triggers a call to the loadClass()
  method of the classloader that loaded the calling

* In these two scenarios, the calling class (c1) is
  found on the shared classpath because c1 is not
  in the webapp's private area.

* In these two scenarios, the c2 class will not be
  found in the shared classpath, nor in any higher
  level class loader - thus ClassNotFoundException
  is thrown.

If you want to refer to a class that is found *only* in the web app's
private class loader (as is true for "c2" in this case), you must do one
of the following things:

* Your calling class (c1 here) must be loaded by the
  same classloader that will load c2.  This is why
  cases (A), (B), (D), (E), and (I) work.

* The calling class (c1 here) must be in a child class
  loader of the class loader that will load c2.  This is
  why case (F) works.

* Your calling class must explicitly acquire the classloader
  for the webapp, and use it to load class c2.  Unfortunately,
  there is no portable way to do this if your calling class was
  loaded by the shared class loader.

Obeying the following restriction will keep you out of classloader
grief:  if a class c1 refers to a class c2 that is loaded by the web app
class loader (i.e. it came from WEB-INF/classes or WEB-INF/lib), then
class c1 MUST also be loaded by the web app class loader.

Craig McClanahan

See you at ApacheCon Europe <>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

View raw message