tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Lavin <>
Subject Deleting URLClassloader Cached Jars/Classes
Date Mon, 02 Apr 2012 18:05:51 GMT

Hi all,
this may be a general Java question or their may be a specific answer 
related to Tomcat.

I am running a simple webservice which loads classes using a 

// start of code snippet
ClassLoader previous = Thread.currentThread()
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.

I suspect that the class is being cached and won't be cleared until the 
JVM restarts (i.e. the Tomcat server will have to be restarted).

My Question:
Is there a way to empty this cache, or disable caching all together?

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

Effectively, I need to clear the cache, all the better if my code can do 
it each time I load the MyClassToBeLoaded.class.


with best regards,
Peter Lavin,
PhD Candidate,
Computer Architecture & Grid Research Group,
Lloyd Institute, 005,
Trinity College Dublin, Ireland.
+353 1 8961536

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

View raw message