尽管每个文件都是正确的ClassNotFound异常

时间:2017-10-11 20:45:07

标签: java jsp servlets web.xml servlet-3.0

我有这种JSP形式:

<form action="SearchData" method="post">
   Name:  <input name="name" size="20" />
   <input type="submit"   value="Search">
</form>

以下是我的XML文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
 <display-name>MongoWebPrj01</display-name>
 <welcome-file-list>
   <welcome-file>Welcome.jsp</welcome-file>
 </welcome-file-list>
 <servlet>
<servlet-name>SearchData</servlet-name>
<servlet-class>MongoWebPrj01.SearchData</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SearchData</servlet-name>
<url-pattern>/SearchData</url-pattern>  <!-- This is the URL of the servlet. 
-->
</servlet-mapping>
</web-app>

这是servlet代码的一部分:

@WebServlet("/SearchData")
public class SearchData extends HttpServlet {
 @SuppressWarnings("null")
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

我正在尝试使用classnotfound excpetion despte尝试所有事情。

我可能在代码中遗漏了什么? 对我来说一切似乎都很好,但它仍然不起作用。

提前致谢!!

编辑:

enter image description here

堆栈跟踪:

SEVERE: Allocate exception for servlet SearchData
java.lang.ClassNotFoundException: MongoWebPrj01.SearchData
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1137)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:858)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

0 个答案:

没有答案