I am trying to scan my webapplication classpath for all classes which implimenting certain interface.
My current application is working fine in stand alone version but failing in the web enviornment.
this is the portion of my code
public String[] getClassPathRoots() {
String classPath;
classPath = System.getProperty("java.class.path");
}
String[] pathElements = classPath.split(File.pathSeparator);
return pathElements;
}
i am not sure how to use java.class.path in my application so as i should be able to get the classpath root.
That property is set to the classpath that the JVM used at launch time. But a typical web container constructs the classpath (i.e. classloader hierarchy) for each webapp dynamically, and doesn’t update the property to reflect this. (And it can’t really, given that a web container may run multiple webapps, and each one will have a different class loader hierarchy. How are you going to represent that in the JVM’s global System properties object?)
In short, you will need to find another way.