tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: [OT] Deleting URLClassloader Cached Jars/Classes
Date Mon, 02 Apr 2012 20:40:17 GMT
Hash: SHA1


On 4/2/12 2:05 PM, Peter Lavin wrote:
> this may be a general Java question or their may be a specific
> answer related to Tomcat.

This is unrelated to Tomcat, since you are using

> I am running a simple webservice which loads classes using a 
> URLClassloader...
> // start of code snippet ClassLoader previous =
> Thread.currentThread() .getContextClassLoader(); URLClassLoader
> loader = new URLClassLoader(new URL[] { new
> URL("http://localhost/classes/")}, previous);
> String className = "common.MyClassToBeLoaded"; Class<?> ho =
> loader.loadClass(className); // end
> This ok, but when I edit and recompile a class which is loaded,
> the changes to are not reflected in the
> webservice.

That's the way most ClassLoaders work: they are designed to cache
classes so that performance doesn't totally suck. Imagine if the JVM
kept having to check to see if java.lang.Object had been updated...

> Is there a way to empty this cache, or disable caching all
> together?

Not without implementing your own ClassLoader. You could read the code
for WebappClassLoader to see how it's done in there.

> There are some suggestions out there but none specific to Tomcat.

That's because this can be done without regard to Tomcat's operation.

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Mozilla -


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

View raw message