tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Lavin <lav...@cs.tcd.ie>
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 
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 MyClassToBeLoaded.java 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.


Peter


-- 
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message