servlet 中Wrapper cannot find servlet 错误!
java源文件:
package org.xhb;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet{
public void doGet(HttpServletRequest req,HttpServletResponse resp) throws
ServletException,
IOException{
PrintWriter out=resp.getWriter();
out.println("<html>");
out.println("<head><title>JSee hubin</title></head>");
out.println("<body>");
out.println("<h1>欢迎进入java EE世界!</h1>");
out.println("</body>");
out.println("</html>");
out.close();
}
}
编译后的class文件放在xhb\WEB_INF\class\org\xhb\下
web.xml配置:
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>org.xhb.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hs</url-pattern>
</servlet-mapping>
tomcat下servlet.xml配置:
<Context path="/lxh" docBase="H:\java\xhb" />
当我运行http://localhost/lxh/时可以正常运行
当运行
http://localhost/lxh/hs时出现如下错误
第一次运行
错误:
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description
The server encountered an internal error () that prevented it from fulfilling this request.exception
javax.servlet.ServletException: Wrapper cannot find servlet class org.xhb.HelloServlet or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
java.lang.Thread.run(Thread.java:619)
root cause
java.lang.ClassNotFoundException: org.xhb.HelloServlet
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
java.lang.Thread.run(Thread.java:619)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
刷新后
错误:
HTTP Status 404 - Servlet hello is not available
----------------------------------