2017-07-01 56 views
0

我在我的web.xml文件中有下面的代碼。我在Tomct服務器上運行我的項目。我faceing以下錯誤:HTTP狀態500 - 實例化servlet類時出錯com.DataFetch

type Exception report message Error instantiating servlet class com.DataFetch description The server encountered an internal error that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: Error instantiating servlet class com.DataFetch 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452) 
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) 
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) 
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
    java.lang.Thread.run(Unknown Source) 
root cause 

java.lang.ClassNotFoundException: com.DataFetch 
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892) 
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735) 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452) 
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) 
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) 
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
    java.lang.Thread.run(Unknown Source) 

而且我的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app id="WebApp_ID" version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
    <display-name>firstServletJsp</display-name> 
    <servlet> 
    <servlet-name>fetch</servlet-name> 
    <servlet-class>com.DataFetch</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>fetch</servlet-name> 
    <url-pattern>/sh</url-pattern> 
    </servlet-mapping> 

</web-app> 
+0

這似乎是你的項目是不正確的構建和部署到tomcat。你用什麼來部署你的項目? –

+0

我手動複製我的應用程序文件夾並複製到webapps文件夾中。 –

+0

你可以在你的問題上寫你的應用程序文件夾結構嗎? –

回答

0

放web.xml中進入的WebContent> WEB-INF文件夾,然後重新生成項目。和示例web.xml代碼: -

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
id="WebApp_ID" version="3.1"> 
<display-name>SecureCloud</display-name> 
<welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
</welcome-file-list> 
<servlet> 
    <servlet-name>fetch</servlet-name> 
    <servlet-class>com.DataFetch</servlet-class> 
</servlet> 
<servlet-mapping> 
    <servlet-name>fetch</servlet-name> 
    <url-pattern>/sh</url-pattern> 
</servlet-mapping> 
</web-app> 
+0

這與他的問題無關,也沒有什麼區別。 –

相關問題