tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Global caching hack?
Date Fri, 16 Jun 2000 17:29:43 GMT
Nacho wrote:

> Hola Craig:
> > Singletons can be problematic in web applications, because
> > what actually
> > happens depends on the way class loaders are implemented in
> > your servlet
> > container.  The portable approach to sharing things throughout a web
> Hmm, How about Pools and other things that have singletons into and are
> not controlled directly by the web application? can be problematic too?

The basic issue is that "static" things are only global across classes
loaded by a particular class loader.  For many servlet containers,
especially those based on the 2.2 spec, each web app will be loaded by a
separate class loader, and you can use Singletons to share things within
that app -- but not between apps.  Some servlet containers use a class
loader per servlet, and may or may not make singletons available across the
entire app.  There may also be differences (between containers) in the way
classes loaded from the system class path are treated versus those loaded
from WEB-INF/classes or WEB-INF/lib/*.jar files.

Relying on singletons makes your app sensitive to an implementation detail
that varies between containers.  It may not be a problem (and is probably
less likely to be a problem in 2.2+ based containers) -- but it might be.
I simply think people should be aware of potential issues when they make
design choices.

> Saludos ,
> Ignacio J. Ortega
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message