tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Asper <>
Subject RE: Best practices for shared classloader use?
Date Tue, 04 Jun 2013 16:55:16 GMT
Thanks for your example and advice, Daniel.

-----Original Message-----
From: Daniel Mikusa []
Sent: Tuesday, June 04, 2013 12:45 PM
To: Tomcat Users List
Subject: Re: Best practices for shared classloader use?

On Jun 4, 2013, at 11:36 AM, Don Asper <> wrote:

> I am considering using the Tomcat 7 shared classloader to reduce the memory footprint
of my web apps.

IMHO, don't do this unless...

  1.) You are very, very sure what you are doing
  2.) You've analyzed the memory savings that you'll achieve by doing this and you are sure
that it is significant compared to the cost of your time if you need to debug a problem.

> But, I'm afraid that loading my application jar files into a single classloader will
cause lots of problems.  I'm aware that the shared classpath should not specify multiple versions
of the same class.  But I suspect, for example, that classes that have static properties must
not be shared.  Am I correct in thinking this?  Are there other problems that I should anticipate?

In my experience, errors of this nature are typically subtle and difficult to debug, another
reason why I'd recommend against this.

My personal favorite error is the ClassCastExceptions that say something like "cannot cast
classX to classX" that occurs when classX from one class loader is attempted to be cast to
classX from another class loader.  There are others, you can probably find some more good
examples by looking back through the list archives.

My advice is to follow the kiss principle and just put your JAR files in with your web application.


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

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

View raw message