tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: WEB-INF classloading and on the fly compilation
Date Fri, 15 Sep 2000 00:30:17 GMT
Nick Bauman wrote:

> On Thu, 14 Sep 2000, Nick Bauman wrote:
>
> > On Thu, 14 Sep 2000 cmanolache@yahoo.com wrote:
>
> > > > On page 24 section 4.6 "a Container Provider ... must ensure that all
> > > > servlets, and classes that they may use, are loaded in the scope of a
> > > > single class loader ..."
> > >
> > > Well, I'm confused - this is how tomcat works. Each context has it's class
> > > loader and all servlets and classes are loaded by that class loader. (
> > > starting with tomcat 3.3 it'll be the URLClassLoader - the
> > > "most" standard/compatible/secure loader we could use).
> > >
> > > Costin
> > >
> >
> > Is it a Singleton? The spec states it should be.
> >
>
> At least that's how it could be interpreted. Maybe what is meant is one
> classloader per context. Any experts on interpretation out there?
>

In 2.2, the scope of this particular statement in the spec is the part of the
sentence that was replaced by ... in the original citation:

    Therefore, when a Container Provider implements a class loading
    scheme for ease of development [i.e. supports automatic reloading
    when classes are changed], they must ensure that all servlets, and
    classes that they use, are loaded in the scope of a single class
    loader guaranteeing that the application will behave as expected by
    the Developer.

In essence, this restricts the container to AT MOST one class loader per web-app
(some early containers used a classloader per servlet to implement autoreload), to
avoid class casting problems.  There are other aspects of the spec that require AT
LEAST one class loader (for instance, the fact that a webapp can see it's own
WEB-INF/classes and WEB-INF/lib/*.jar but not any from other webapps), so it's
pretty clear that there is a one-to-one relationship between webapps and
classloaders.  That's the way it's implemented in Tomcat 3.x and 4.0 as well.

In 2.3, there is specific reference to the "Web Application Classloader" (Section
9.6.2) plus some additional requirements on the order in which the various
repositories are searched and respecting declared version dependencies between JAR
files.

Craig

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



Mime
View raw message