tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrés Aguiar <>
Subject ClassLoader & Reloading issues
Date Mon, 20 Aug 2001 03:24:57 GMT
I have a JAR file in my web-inf\lib directory that has an object pool. The
pool is kept as a singleton, so, I have a static member with it.

The problem is that when a class in web-inf\classes is reloaded, it seems to
use a new classloader, so the static member is gets not the same as it was,
and I end having multiple object pool instances.

If I put the .JAR in the Tomcat classpath, it obviously works ok.

The problem is that I must keep running in the same servlet-engine instance
several applications each of which could a have a different version of my
.JAR file, so I can't put it in the classpath.

The same happens running the app in Resin.

Now, in the servlet spec says:

'Although a Container Provider implementation of a class reloading scheme
for ease of development is not required, any such implementation must ensure
that all servlets, and classes that they may use, are loaded in the scope of
a single class loader. This requirement is needed to guarantee that the
application will behave as expected by the Developer. 

As a development aid, containers are encouraged to maintain the full
semantics of notification to session binding listeners if they
determine to terminate sessions in order to reload classes.

Previous generations of containers created new class loaders to load a
servlet, distinct from class loaders used to load other servlets or classes
used in the servlet context. This could cause object references within a
servlet context to point at unexpected classes or objects, and cause
unexpected behavior.'

I'm not sure if this paragraph is referring to the case I'm describing, but
if not, it seems pretty close...

Any ideas? Is this the way it's supposed to work?


View raw message