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

求救!Servlet运行出错!Wrapper cannot find servlet class 小弟我快疯了

2013-09-11 
求救!Servlet运行出错!Wrapper cannot find servlet class 我快疯了编写了一个简单的Servlet,HelloWorld.j

求救!Servlet运行出错!Wrapper cannot find servlet class 我快疯了
编写了一个简单的Servlet,HelloWorld.java
package   test;

import   java.io.*;
import   java.text.*;
import   java.util.*;
import   javax.servlet.*;
import   javax.servlet.http.*;

public   class   HelloWorld   extends   HttpServlet
{
public   void   doGet(HttpServletRequest   request,HttpServletResponse   response)
throws   IOException,ServletException
{
response.setContentType( "text/html ");
PrintWriter   out   =   response.getWriter();out.println( " <html> ");
out.println( " <head> ");
                  out.println( " <title> HelloWorld </title> ");
out.println( " </head> ")
out.println( " <body> HelloWorld </body> ");
out.println( " </html> ");
}
}
环境变量
JAVA_HOME=C:\j2sdk1.4.2_13
CATALINA_HOME=C:\Program   Files\Apache   Software   Foundation\Tomcat   5.0
CLASSPATH=C:\j2sdk1.4.2_13\lib\dt.jar;C:\j2sdk1.4.2_13\lib\tool.jar;C:\j2sdk1.4.2_13\lib\tools.jar;C:\Program   Files\Apache   Software   Foundation\Tomcat   5.0\common\lib\servlet-api.jar;C:\Program   Files\Apache   Software   Foundation\Tomcat   5.0\common\lib\jsp-api.jar

Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\j2sdk1.4.2_13\bin

将编译完后的HelloWorld.class放入%CATLINA_HOME%\webapps\servlet\WEB-INF\classses\test\目录下
并且修改了servlet\WEB-INF\下的web.xml
<?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>
    <display-name> my   program </display-name>
    <description>
          test
    </description>
   
    <servlet>
    <servlet-name> HelloWorld </servlet-name>
    <display-name> HelloWorld </display-name>
    <description> A   test   Servlet </description>
    <servlet-class> test.HelloWorld </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> HelloWorld </servlet-name>
    <url-pattern> /HelloWorld </url-pattern>
    </servlet-mapping>
</web-app>
重新启动Tomcat,但是在浏览器中输入http://127.0.0.1:8080/webapps/servlet/HelloWorld
出现下面的错误
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   test.HelloWorld   or   a   class   it   depends   on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)


org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)


root   cause  

java.lang.ClassNotFoundException:   test.HelloWorld
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:534)


note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Apache   Tomcat/5.0.29   logs.

无法定位class文件啊,郁闷啊,上次写javabean时也是类似的错误,也找不带class文件,但是我的class文件已经放在相应文件夹下了啊,我都快疯了。。。。大家救救我啊

[解决办法]
基本上是没有错, 不过你
应该在浏览器中输入http://127.0.0.1:8080/servlet/HelloWorld
[解决办法]
servlet才是你的服务目录
[解决办法]
Web.xml配置没问题,servlet也没问题,
如果你没有去改动tomcat本身的配置文件的话,你就按楼上所讲的一样,输入http://127.0.0.1:8080/servlet/HelloWorld
[解决办法]
错误提示就是找不到HelloWorld类,就是路径输错了,不应该要webapps
[解决办法]
ls几位都是正确的,webapps这个目录是不需要的
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行