I'm trying to deploy a Tomcat application by copying it to the webapps
directory. My webapps
directory looks like:
webapps/test
|_ index.jsp
|_ WEB-INF
|_ lib
|_ test.jar
The contents of index.jsp
are:
<html>
Test App<br>
<%= com.stevekuo.Test.test() %>
</htm>
test.jar
has the Test
class with the static test()
method that just returns a string.
When I access my app via http://tomcatserver:8080/test/
, all I get is:
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: 3 in the jsp file: /index.jsp
com.stevekuo.Test cannot be resolved to a type
1: <html>
2: Test<br>
3: <%= com.stevekuo.Test.test() %>
4: </html>
I've also tried packaging the above directory structure into a WAR file and copying to webapps
, but it still gives the same error.
I'm running standard out-of-the-box Tomcat 6 on Ubuntu 10.04. Tomcat came installed by Ubuntu. All files have -rw-r--r--
permissions, and directories are drwxr-xr-x
. Why can't Tomcat resolve the Test
class located in WEB-INF/lib/test.jar
?
have you imported com.stevekuo.Test
you need to say <%@ page import="com.stevekuo.Test"%>
this is most definitely the fault.
Resolved. I added an empty web.xml
and it works.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
</web-app>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.