Hi
I am trying to use the following code to load a class from a jar file
which is outside of my webapp directory. The classes are loaded on
demand and dynamically.
...
public class JarClassLoader extends URLClassLoader {
public JarClassLoader(File jar) throws MalformedURLException {
super(new URL[] { jar.toURL() });
}
public Object instantiate(String className) throws
ClassNotFoundException, InstantiationException, IllegalAccessException {
System.out.println("Looking for class: " + className);
Class c = findClass(className);
return c.newInstance();
}
}
...
JarClassLoader loader = new JarClassLoader(new File(jarPath));
Object o = loader.instantiate(myClassName);
...
If I run the code from an app, it loads without any problems. If I use
it within a tomcat Servlet, the 'instantiate' call throws a
java.lang.NoClassDefFoundError.
I have checked that the tomcat user can access the jar file, so it does
not seem to be a permission problem.
Does the tomcat container limit access to classes outside of its
classpath? Is there something simple I am missing?
Regards
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]