I have recently upgraded to Tomcat 4.0.1 and my JSP pages are no longer finding my classes in:
$CATALINA_HOME/webapps/mycontext/WEB-INF/classes
I can get the JSP pages to work if I put an '@import page' command in it to explicitly reference my class, but do I have to do this with Tomcat 4? My previous tomcat configuration found my classes automatically.
I have checked/tried the following:
- Putting the classes in the $CATALINA_HOME/common/classes dir
- Putting the classes in the
$CATALINA_HOME/classes dir
- Putting the classes in a jar file in all the appropriate 'lib' directories.
- Putting all the classes and lib directories in the CLASSPATH (both in the Unix env variable and in the Tomcat startup script catalina.sh)
- Checked the unix file permissions of all directories/files.
But it
still does not seem to find the classes!
Please Help!, it's driving me mad!
I have not defined a context in servers.xml (Tomcat does it automatically using defaults) and my context web.xml contains almost nothing.
This is my class (Test.java/Test.class):
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Test extends HttpServlet
{
public static String HelloWorld()
{
return "This is from Hello World servlet!";
}
}
This is the jsp page that works (with page import):
<%@page import="Test" %>
<p>Test Page</p>
<%=Test.HelloWorld()%>
This is the jsp page that does not (without page import):
<p>Test Page</p>
<%=Test.HelloWorld()%>
This is the error I am getting on the second jsp:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 5 in the jsp file: /test2.jsp
Generated servlet error:
/hfx/opt/jakarta-tomcat-4.0.1/work/localhost/dba_site/test2$jsp.java:58: Undefined variable or class name: Test
out.print(Test.HelloWorld());
^
1 error
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:189)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
etc...
etc...