Hi Dmitry,
Sorry, everyone, if this seems to be slanting a little
off-topic, but I think Xalan's extension loading merits
an attempt to understand this stuff to the dot ...
> First, how a class loader finds classes is completely up to the particular
At second glance, I guess that's right ... the
behavior I described is specified in the docs of
java.lang.ClassLoader, which led me to regard it
as the general contract for classloaders, but I
guess it's just the default implementation. Thanks!
> 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.
I don't think this is precise. "Postfix and prefix"
implies subtree traversal to me, but the two schemes
you describe seem to be:
"postfix": the normal ancestor chain lookup (parent-first)
"prefix": the normal ancestor chain lookup (myself-first)
which has nothing to do with tree search. I don't know,
maybe Tomcat made that change, but in any case, the common
classloader does not search its children. If it did, that
would be asking for deployment woes ... it would be version
conflicts galore.
The new scheme of classloading in Tomcat is explained there:
http://jakarta.apache.org/tomcat/tomcat-3.3-doc/tomcat-ug.html#configuring_t
omcat
and it still only searches "rootwards" for classes. The main
difference is that Tomcat's own classes are in a separate
classloader that the webapps don't see, instead of in the
common classloader as they were in 3.2 and older. This is to
minimize the amount of "extraneous" classes that webapps have
to see (in particular, they don't have to have Tomcat's JAXP
or parser jars in their face). But you still have to locate
your extension classes in Xalan's classloader or one of its
ancestors -- that hasn't changed. So in Tomcat 3.3 the normal
thing to do is to put Xalan and all extension classes in the
common classloader, ${tomcat_home}/lib/common, just as in
Tomcat 3.2 the normal thing to do is to put put Xalan and all
extension classes in the Tomcat classloader, ${tomcat_home}/lib.
... I think. :)
If I'm still confusing myself, please set me straight! :)
Cheers,
- Gulli