tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: Wish to use an independent class module in Tomcat
Date Tue, 26 Jun 2012 16:15:41 GMT
2012/6/26 Cotton, Joseph B <>:
> My question may be covered by the Tomcat documentation and I am just
> confused by all the new terminology.  I have spent hours in reading and
> still I am looking to an answer.
> We wish to have a class running on Tomcat that contains system wide info
> and multiple database connections into DB2 on the mainframe.   All other
> apps runing on Tomcat will open an instance of this class to access the
> static info and one of five open connections.  Opening and closing
> database connections is very slow and we wish to leave open the
> connections and just reuse them as needed.
> We wrote the class and it runs ok.  Yet to get it to run with an app, we
> need to load the class jar file into the app and references in
> context.xml and web.xml as listed in the documentation. But that defeats
> the purpose of the global app because then there are multiple instances
> of the class.
> We tried to insert a reference in <GlobalNamingResources> of server.xml.
> It doesn't seem to work for us.
> Or are we off base with this design?  Is app to app communication
> allowed?  Can I call a class from one app to another without first
> loading the called class into the calling class?

The first thing you need to consider in your scenario is behaviour of
This is documented here:

One caveat is that, for the reasons documented there, when you put
some class into the Common classloader,  you must remove it from your

Other caveat is that such global objects should not retain references
to objects loaded by your web application or to its classloader (which
is Thread.getContextClassloader() aka TCCL).  The lifecycle of a
webapplication is shorter than the one of Tomcat. A failure to prevent
such references will prevent proper garbage collection of web
application classes when the application is stopped.

As for GlobalNamingResources,  there are several ways to pass a
reference to a global object into the web application.  Using JNDI
(via GlobalNamingResources or directly) is one of them.

Best regards,
Konstantin Kolinko

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message