最近在学习Java Servlet,正拜读O 'REILLY系列的Java书籍中的《Java Servlet编程》,在运行第三章的一个例子(该例子还是从O 'REILLY网站上下载的)的时候出现了下面这个问题:找不到HttpServlet类,一般像该类问题到底是什么原因造成的呢(估计是路径问题没搞好)?还请哪位高手顺便说说Tomcat在运行Servlet程序时的查找路径是从哪开始找的呢?明明存在javax/servlet/http包但却找不着?看看到底如何解决该的错误......谢谢......谢谢......
不甚感激......!!!
本机运行环境变量如下:
classpath:%JAVA_HOME%\bin;.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;E:\Program Files\Java\tomcat-6.0.10\lib\servlet-api.jar;E:\Program Files\Java\com.oreilly.servlet\lib\cos.jar
JAVA_HOME:E:\Program Files\Java\jdk1.5.0_09
Path:%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%JAVA_HOME%\bin;E:\Python24;E:\Program Files\Java\tomcat-6.0.10\lib\servlet-api.jar;C:\masm32\BIN
TOMCAT_HOME:E:\Program Files\Java\tomcat-6.0.10
运行错误提示如下:(其中已经对web.xml设置好了注册名和运行所需要的类)
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: Error allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
java.net.URLClassLoader.defineClass(Unknown Source)
java.net.URLClassLoader.access$100(Unknown Source)
java.net.URLClassLoader$1.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1815)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)