0

我有一个由 Java servlet 和 JSP 组成的 Web 应用程序,我正在尝试在 Netbeans 中作为 Maven 项目工作。我已经让它在 Linux 以及 Netbeans 中运行,但作为常规 Web 项目,而不是作为工作所需的 Maven 项目。

Tomcat 似乎正在工作,因为当我单击“运行”按钮时,我的 index.jsp 会出现,但是当我尝试访问我的 HelloServlet 时,它给了我:

HTTP Status 500 - Error instantiating servlet class test.HelloServlet
type Exception report

message Error instantiating servlet class test.HelloServlet

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class test.HelloServlet
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
java.lang.Thread.run(Thread.java:662)

根本原因

java.lang.ClassNotFoundException: test.HelloServlet
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
java.lang.Thread.run(Thread.java:662)`

这是我的 web.xml:

<servlet>
    <servlet-name>hello</servlet-name>
    <servlet-class>test.HelloServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>DisplayDeleteForm</servlet-name>
    <servlet-class>test.DisplayDeleteForm</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>hello</servlet-name>
    <url-pattern>/helloServlet</url-pattern>
</servlet-mapping>
<servlet>
    <servlet-name>add</servlet-name>
    <servlet-class>test.DisplayAddForm</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>add</servlet-name>
    <url-pattern>/displayAddForm</url-pattern>
</servlet-mapping>
<servlet>
    <servlet-name>submit</servlet-name>
    <servlet-class>test.SubmitForm</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>submit</servlet-name>
    <url-pattern>/submitForm</url-pattern>
    <http-method>POST</http-method>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>DisplayDeleteForm</servlet-name>
    <url-pattern>/displayDeleteForm</url-pattern>
</servlet-mapping>

我很确定这与我如何组织文件夹和存储文件有关,但我看不到它。

任何帮助是极大的赞赏!!

谢谢,德文

4

0 回答 0