目前我使用的Ubuntu 12.04LTS,Eclipse IDE中和Apache Tomcat 7.0.27,我没有完成工作。
我做了一个简单的JSP页面“的index.jsp”,这是“的WebContent / index.jsp的”。 我做了一个名为“EmployeeClass”这是包“com.pack.web”里面的servlet。 在Jsp页面我有get方法,并作为后续行动一个形式:
<form method="GET" action="hidden.do">
在web.xml中我也有:
<servlet>
<servlet-name>Searcher</servlet-name>
<servlet-class>com.pack.web.EmployeeClass</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Searcher</servlet-name>
<url-pattern>/hidden.do</url-pattern>
</servlet-mapping>
我做了一个简单的servlet“EmployeeClass”,它在包:
package com.pack.web;
在这个servlet我有一个doGet方法为:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Something is happening");
}
我终于然后运行我的项目,打提交按钮后,轰的一声我有这样的:
javax.servlet.ServletException: Error instantiating servlet class com.pack.web.EmployeeClass
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:662)
根本原因
java.lang.ClassNotFoundException: com.pack.web.EmployeeClass
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:662)