首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

servlet 中Wrapper cannot find servlet 异常

2013-09-11 
servlet 中Wrapper cannot find servlet 错误!java源文件:package org.xhbimport java.io.*import javax

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

--------------------------------------------

type Status report

message Servlet hello is not available

description The requested resource (Servlet hello is not available) is not available.



我只知道是路径错误,就是不知道哪里错了,如何改
请各位大侠指点指点谢了!!!!

[解决办法]
应该放在\WEB_INF\classes下
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行