Problem with dynamic class loading

Hi,

We have a class file in an external jar(outside ear) and access it in an ear using classloader.loadClass method. But if the class file is changed in jar, it gets hotdeployed in jboss but code which calls this class still refers to the old code.

Class getClassByName(String className) throws ClassNotFoundException {

Class theClass = null;

try {

theClass = Thread.currentThread().getContextClassLoader().loadClass(className);

} catch (ClassNotFoundException e) {

theClass = getClass().getClassLoader().loadClass(className);

}

return theClass;

}

When I looked into api I came to know that loadClass actually loads the class if it is not already exists. Can any one help me in writing thecustom class loader which loads the class everytime instead of checking previous instance before loading......

Thanks,

Kruthika

[902 byte] By [kruthikaa] at [2007-11-27 9:16:24]
# 1
You probably have to get rid of the class loader that loads the original version and start with a new class loader.
bsampieria at 2007-7-12 22:06:07 > top of Java-index,Java Essentials,Java Programming...
# 2
Could you pls give an example considering the code I have posted?
kruthikaa at 2007-7-12 22:06:07 > top of Java-index,Java Essentials,Java Programming...
# 3
Does this tech tip help? (The second one :-) http://java.sun.com/developer/JDCTechTips/2003/tt0819.html
BigDaddyLoveHandlesa at 2007-7-12 22:06:07 > top of Java-index,Java Essentials,Java Programming...