
June 23rd, 2009, 02:01 PM
|
|
C# Cultist
|
|
Join Date: Jul 2004
Location: Sterling, VA
Posts: 93
  
Time spent in forums: 1 Day 2 h 9 m 52 sec
Reputation Power: 7
|
|
|
Tomcat Java Classes
I am trying to get a simple JSP page working under Tomcat and failing miserably.
Error message:
Code:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the generated java file
Only a type can be imported. bll.User resolves to a package
An error occurred at line: 3 in the jsp file: /index.jsp
User cannot be resolved to a type
1: <%@page import="bll.User"%>
2: <%
3: User x = new User();
4: x.setFirstName("Some");
5: x.setLastName("Guy");
6: %>
An error occurred at line: 3 in the jsp file: /index.jsp
User cannot be resolved to a type
1: <%@page import="bll.User"%>
2: <%
3: User x = new User();
4: x.setFirstName("Some");
5: x.setLastName("Guy");
6: %>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:616)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:537)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
The JSP page (index.jsp):
Code:
<%@page import="bll.User"%>
<%
User user = new User();
user.setFirstName("Some");
user.setLastName("Guy");
%>
<html>
<head>
<title>test</title>
</head>
<body>
<p><%= u.getFullName() %></p>
</body>
</html>
The User class:
Code:
package bll;
public class User
{
private String firstName;
private String lastName;
public User()
{
}
public String getFirstName()
{
return this.firstName;
}
public void setFirstName(String value)
{
this.firstName = value;
}
public String getLastName()
{
return this.lastName;
}
public void setLastName(String value)
{
this.lastName = value;
}
public String getFullName()
{
return this.getFirstName() + " " + this.getLastName();
}
}
web.xml:
Code:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 1.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
</web-app>
File and directory structure:
Code:
dtucker@dtucker-vm:/usr/share/tomcat6/webapps/test$ ls -lR
.:
total 12
drwxr-xr-x 3 root root 4096 2009-06-23 10:59 classes
-rw-r--r-- 1 root root 207 2009-06-23 13:47 index.jsp
drwxr-xr-x 2 root root 4096 2009-06-23 10:45 WEB-INF
./classes:
total 4
drwxr-xr-x 2 root root 4096 2009-06-23 11:00 bll
./classes/bll:
total 8
-rw-r--r-- 1 root root 788 2009-06-23 13:32 User.class
-rw-r--r-- 1 root root 470 2009-06-23 10:59 User.java
./WEB-INF:
total 4
-rw-r--r-- 1 root root 152 2009-06-23 10:45 web.xml
CLASSPATH and JAVA_HOME:
Code:
dtucker@dtucker-vm:~$ echo $CLASSPATH
/usr/share/tomcat6/webapps/test/classes
dtucker@dtucker-vm:~$ echo $JAVA_HOME
/usr/lib/jvm/java-6-openjdk
Does anybody have any ideas? I can provide any other information that might be needed.
|