(jsp) class loader not finding generated JSP class

U

unixfreak0037

I hope my subject line is close enough. Assume a JSP file that calls a
static function "A" on some class. "A" then goes down the stack
looking for what class called it. It then tries to get a Class object
for that class with forName.

It works when the function is called from a class I create outside of
the JSP. But when called from inside a JSP scriptlet, the className it
finds on the stack is one (I assume is) genated by the compile from JSP
into a Java class file, and it does not find that one. I get the
ClassNotFound exception.

So I guess that means the class loader can't find it, so I would then
guess that there is more than one class loader and I'm not using the
right one in a call to forName. Am I on the right track here?

I'm using Tomcat 5.5.7.

john
 
A

Andrea Desole

I hope my subject line is close enough. Assume a JSP file that calls a
static function "A" on some class. "A" then goes down the stack
looking for what class called it. It then tries to get a Class object
for that class with forName.

It works when the function is called from a class I create outside of
the JSP. But when called from inside a JSP scriptlet, the className it
finds on the stack is one (I assume is) genated by the compile from JSP
into a Java class file, and it does not find that one. I get the
ClassNotFound exception.

So I guess that means the class loader can't find it, so I would then
guess that there is more than one class loader and I'm not using the
right one in a call to forName. Am I on the right track here?

Probably. You can check it by looking at the class loader and its
parents, finding out where they look for classes. You should also be
able to debug the generated jsp, to see what class loader is used there.
How to solve the problem, I don't know. What you are trying to do is
very strange, and it's probably related to the specific
implementation/configuration of the server. Maybe you can add the needed
jars/directories to the classpath. I don't know what your goal is, but I
personally would think of a different solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top