Sometimes in a java environment, you find yourself in a situation where you really don’t understand why you can’t make your bug disappear, and begin to think the class is loading from an old, stale version.
Well stop scratching your head, you can display where exactly a class is loading from !

Here is the correct way to do it :

private void displayLoadPath(Class inClass) {
String ClassAsRessourceName = inClass.getName()
.replaceAll(« \. », « / ») + « .class »;
ClassLoader xcl = inClass.getClassLoader();
java.net.URL urlJar =
xcl.getResource(
ClassAsRessourceName);
logger.debug(inClass +  » : loaded from path  » + urlJar );
}

Tested under jboss 4.2.1, call this function with myClass.class argument.