You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by um...@comcast.net on 2008/01/12 16:05:39 UTC
Classloader Problems: loading webapp classes using commons CL
Env: Tomcat 6.0.14, JRE1.6
I have an application comprising a number of distinct webapp contexts
which use a common version of certain jarfiles. Loading an instance of
the jarfiles by each webapp classloader takes up a lot of memory.
Hence, I have moved these jarfiles to ${CATALINA_BASE}/lib. So we have:
"common classes" ==> ${CATALINA_BASE}/lib
"webapp-specific classes" ==> ${CATALINA_BASE}/webapps/<foo>/WEB-INF/lib
This has been the beginning of my problems: the common classes
make direct and indirect references to the webapp-specific classes
during the context loading. As an example, a webapp invokes digester
at context load. While the digester itself is present in "commons classes",
the digester rules refer to webapp-specific classes. This causes the digester
to fail, thus aborting the context with a listenerStart ERROR message. This seems
occur because since digester is loaded by commons classloader, it has
no access to the webapp-specific classes.
Carried to an extreme, I would have to place all of webapp-specific classes
in ${CATALINA_BASE}/lib as well. Clearly this would be broken.
Here are my questions:
1) There must be a way to neatly factor out into common classloader classes shared
by a number of cooperating webapp contexts. What would such a scheme be?
2) In the lifecycle of a webapp context:
- when is the webapp classloader "born"?
- is the webapp classloader loaded by the commons classloader or the system classloader?
- which classloader loads the context loader listener?
Pl help - I have been chasing my own tail with this problem for quite sometime!
Thanks,
/U
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Classloader Problems: loading webapp classes using commons CL
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: uma_rk@comcast.net [mailto:uma_rk@comcast.net]
> Subject: Classloader Problems: loading webapp classes using commons CL
>
> This has been the beginning of my problems: the common classes
> make direct and indirect references to the webapp-specific classes
> during the context loading.
"Doctor, doctor, it hurts when I do this."
So stop doing it.
You've encountered some of the reasons why putting not-quite-independent
classes in the common library is pretty much always a bad idea. The
right thing to do is juse leave them in WEB-INF/lib of each webapp.
Yes, it eats up a bit more PermGen space, so increase it. It will make
your life so much easier.
Here's the doc on Tomcat classloading, in case you haven't found it yet:
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org