File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "URLClassloader in webapp" Watch "URLClassloader in webapp" New topic

URLClassloader in webapp

Askar Kalykov

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"
I agree. Here's the link:
subject: URLClassloader in webapp
It's not a secret anymore!