Gulli,
I will disagree on a couple of accounts, if I may,
First, how a class loader finds classes is completely up to the particular
classloader. For example, it is my understanding that in Tomcat 3.2 and
prior, the classloader would do a postfix traversal of the loader
hierarchy, that is, it would first delegate loading to the parent loader
and if the parent couldn't locate the class, then it would apply its own
heuristics, whatever they are. In Tomcat 3.3 & 4.0, this behavior has been
changed to prefix traversal.
It "should" be possible to place xalan.jar in ${tomcat_home}/lib and have
it shared by all the applications, but apparently, currently it doesn't
work. Hence, my problem. That's because when xalan is in tomcat's lib
directory, it's been loaded by Tomcat's classloader (not the application
loader) and it actually always stays withing the context of that
classloader (that's why I believe that getContextClassLoader() call doesn't
really do anything useful).
Regards
Dmitry
At 12:26 PM 8/13/2001, Gunnlaugur Thor Briem wrote:
>Hi,
>
>just to clear it up for everyone, the fix makes perfect sense,
>but no, it isn't necessary to copy xalan.jar into every webapp.
>
>It makes sense because you made sure that xalan.jar was found by
>the same classloader as your extension classes. That is the real
>requirement. You satisfied this requirement by placing xalan.jar
>in the webapp classloader, where the extension classes were. If
>the same xalan.jar needs to be available to ALL webapps in the
>servlet engine (which it probably usually does) then you should
>instead satisfy this requirement by placing the extension classes
>in the ${tomcat_home}/lib, where xalan.jar was originally. Either
>way will work -- they just need to be together.
>
>Actually, to be pedantically precise, having xalan.jar in the
>webapp lib and the extension classes in ${tomcat_home}/lib would
>also work (though it would be a pretty silly configuration)...
>the extension classes need to be accessible to Xalan's classloader,
>and they are, if they are defined in that classloader or one of its
>ancestor classloaders. The ${tomcat_home}/lib classloader is the
>parent or ancestor classloader of any webapp classloader, hence
>any class defined in it is available in any webapp.
>
>This is all crystal-clear if you know how a ClassLoader finds its
>classes. When asked to find a class, any ClassLoader will first
>ask its parent classloader and then try to to find the class
>itself, but will not ask any of its child classloaders (I believe
>it doesn't even know about them). For the complete story, see
>http://java.sun.com/j2se/1.3/docs/api/java/lang/ClassLoader.html
>
>Hope that leaves no trace of confusion! :)
>
> - Gulli
>