Bug 38877 - Loader tag in server.xml induces a wrong class loading scheme
Summary: Loader tag in server.xml induces a wrong class loading scheme
Status: RESOLVED DUPLICATE of bug 37054
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.16
Hardware: Other other
: P2 major with 2 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-07 10:59 UTC by Mathieu
Modified: 2006-04-24 06:53 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mathieu 2006-03-07 10:59:55 UTC
When you have a "Loader" tag for your "context" in the "server.xml" file, the
class loading scheme of tomcat is broken.

In this case, your custom Loader receieves, as a parent ClassLoader, an instance
of the System ClassLoader, instead of an instance of the Shared ClassLoader (see
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html).

This is because, when the "Loader" tag is present, the custom loader (typically
a subclass of "WebappLoader") is created while reading the XML file, BEFORE
knowing the parent container (and therefore, defore knowing the parent
ClassLoader = Shared ClassLoader) [class ContextRuleSet, method begin(),line 253].

In this case, the default class loader is set to the SystemClassLoader [class
ContainerBase, method getParentClassLoader(), line 580].

On the other hand, if you DON'T have the tag, the loader is created later [class
StandardContext, method start, line 4022].

I consider this bug a a major one, as the class loading scheme is broken (I
consider class loading as a fundamental element of J2EE). This bug prevents an
easy professionnal development of web applications, as it imposes the manual
copy of classes and jars into the apposite WEB-INF locations, instead of using a
suited class loader allowing an easy share of classes between projets.

Related bugs: ASF Bugzilla Bug 37054, ASF Bugzilla Bug 37302.

Mathieu
Comment 1 Yoav Shapira 2006-04-14 18:57:13 UTC
There are plenty of ways to easily share classes and their object instances
between webapps without using a custom loader ;)  But I'll leave this bug open,
we'll see if anyone cares to submit a patch.
Comment 2 Remy Maucherat 2006-04-24 13:53:00 UTC

*** This bug has been marked as a duplicate of 37054 ***