aspose file tools*
The moose likes Servlets and the fly likes URLClassloader in webapp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "URLClassloader in webapp" Watch "URLClassloader in webapp" New topic
Author

URLClassloader in webapp

Askar Kalykov
Greenhorn

Joined: Oct 22, 2006
Posts: 1
I'm using url-classloader in my webapp.
In general, there is class A:


on ServletContextListener.init() A.init() is called, and on ServletContextListener.destroy() A.destroy() is called.

Objects created by that classloader are used in TimerTasks (no references to TimerTasks are stored).
Before calling A.destroy(), I'm calling .cancel() on Timer, that invokes those TimerTasks.

The problem is: on webapp unloading Tomcat erases all but jars, that has been used, when creating classloader in createClassLoader() method, therefore Tomcat can not fully unsinstall or redeploy that webapp.

How can I unload objects and classes loaded by my classLoader?
Is this problem somehow related to Timer, that I'm using for working with that objects?
[ October 22, 2006: Message edited by: Askar Kalykov ]

open your eyes
D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

Do you use standard URL class loader? Are your classes in http:// form? If you use file:/ based URL then classes can be locked and can't be deleted.


Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
 
jQuery in Action, 2nd edition
 
subject: URLClassloader in webapp
 
Similar Threads
Loading POJO object without loading library first
How to set a new Custom ClassLoader?
inner class doubt
String literals and memory.
How to Load Serialized Plugins?