I am trying to use URLClassLoader class tor retrieve information about a class in the local file system, using the version 4.0.5 of the JBoss application server.
I have a business function in a session bean class in which i do this:
String classPathString = path;
File classPath = new File(classPathString);
File[] files = classPath.listFiles();
try {
URLClassLoader classLoader;
Thread.currentThread().setContextClassLoader(
classLoader = new URLClassLoader(
new URL[] {files[0].toURL()}
)
);
Class c = classLoader.loadClass("classbro.ejb.JClassBroBean");
return c.getName();
} catch(ClassNotFoundException e) {
return "Class not found.";
} catch(MalformedURLException e) {
return "Malformed URL.";
}