I'm building an application using Ajax,jsp and Java. I meet the problem when I call Java reflection by Ajax call. This is the error:
Feb 22, 2014 11:39:13 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [optSim] in context with path [/Manager] threw exception
java.lang.RuntimeException: No resource for it/Manager/Support
the code that thrown the exception is:
public static Vector<Class> getClassesForPackage(Package pkg) {
String pkgname = pkg.getName();
Vector<Class> classes = new Vector<Class>();
// Get a File object for the package
File directory = null;
String fullPath;
String relPath = pkgname.replace('.', '/');
System.out.println(System.getProperty("java.class.path"));
// System.out.println("ClassDiscovery: Package: " + pkgname +
// " becomes Path:" + relPath);
System.out.println(System.getProperty("java.class.path"));
URL resource = ClassLoader.getSystemClassLoader().getResource(relPath);
// System.out.println("ClassDiscovery: Resource = " + resource);
if (resource == null) {
throw new RuntimeException("No resource for " + relPath);
}
....
In input this method take a package name and it search the class in the selected package. The problem is that if I call the method by jar file without Ajax this run correctly, otherwise return an error.
I print javaclass path and it contains the directory src where are it/Manager/Support.
I thinks that the problem is in tomcat configuration.
Can anybody help me?
Thanks very Much