2012-07-14 59 views
-1

我已經開發了一個簡單的servlet,通過在Eclipse中選擇dynamci項目顯示below..in日食...關於servlet的錯誤,同時部署

的servlet ..

package com.demo; 

import java.io.IOException; 
import java.io.PrintWriter; 

import javax.servlet.ServletException; 
import javax.servlet.annotation.WebServlet; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 

    public class Myservlet2 extends HttpServlet { 
     private static final long serialVersionUID = 1L; 


     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 

      System.out.println("Servlet 2 of App2 invoked..."); 
      response.setContentType("text/html"); 
      PrintWriter out=response.getWriter(); 
      out.println("This output is generated by servlet2 of app2"); 
      out.close(); 

     } 
    } 

和網絡。 XML是...

<servlet> 
<servlet-name>Myservlet2</servlet-name> 
<servlet-class>com.demo.Myservlet2</servlet-class> 
</servlet> 
<servlet-mapping> 
<servlet-name>Myservlet2</servlet-name> 
<url-pattern>/servlet2</url-pattern> 
</servlet-mapping> 

在通過月食,我得到了下面的錯誤在Tomcat中部署它..

java.lang.ClassNotFoundException: com.demo.Myservlet2 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556) 
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525) 
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507) 
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:124) 
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1136) 
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) 
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) 
    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:999) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) 
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 

請這可怎麼提前corrected.Thanks

+0

這是更好,如果你開始閱讀一些好的教程庫罐子。在發佈的所有四個問題中,您的錯誤類型幾乎相同 – 2012-07-16 07:25:59

回答

0

檢查類com.demo.MyServlet2存在於WEB-INF/classes或位於WEB-INF/lib

相關問題