G
Gaurav
Hi,
I have a method getData() in class DataAccess which internally calls a
method in a class inside a jar. The method inside the jar has
somehting like this:
Class.getForName("mypackage.myclass").newInstance();
The class instantiation works perfectly fine when I call getData()
from a main() method inside DataAcess. But I get a
ClassNotFoundException when I try to access the getData() method from
a web application (servlet container-Tomcat).
For the sake of debugging I added the line
Class.getForName("mypackage.myclass").newInstance(); inside the
getData() method itself. I observed there was no error when this line
was executed in getData() even when accessing the method from the
servlet.
Thus I only get the ClassNot FoundException inside the jar when I try
to access the method from the web application.
Someone suggested that this could be a classloader issue as there are
multiple classloaders in case of servlet but I am not really sure how
to resolve it.
I would be grateful if someone could provide some suggestions.
Note: The class in the jar reads the class name (mypackage.myclass)
from an XML file but I did put a debugger and observed that the
correct name was being sent to the jar.
TIA,
Gaurav
I have a method getData() in class DataAccess which internally calls a
method in a class inside a jar. The method inside the jar has
somehting like this:
Class.getForName("mypackage.myclass").newInstance();
The class instantiation works perfectly fine when I call getData()
from a main() method inside DataAcess. But I get a
ClassNotFoundException when I try to access the getData() method from
a web application (servlet container-Tomcat).
For the sake of debugging I added the line
Class.getForName("mypackage.myclass").newInstance(); inside the
getData() method itself. I observed there was no error when this line
was executed in getData() even when accessing the method from the
servlet.
Thus I only get the ClassNot FoundException inside the jar when I try
to access the method from the web application.
Someone suggested that this could be a classloader issue as there are
multiple classloaders in case of servlet but I am not really sure how
to resolve it.
I would be grateful if someone could provide some suggestions.
Note: The class in the jar reads the class name (mypackage.myclass)
from an XML file but I did put a debugger and observed that the
correct name was being sent to the jar.
TIA,
Gaurav