javax.servlet.ServletException: Wrapper cannot find servlet class

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

I have made a servlet from "Jasper Reports for Java Develper" (chapter 3) which will show Jasper Report on browser.

The servlet look like below:

public class FirstReportSendToBrowserServlet extends HttpServlet {      //just implement doGet in the block     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {                        // ...                 } } 

Then I compiled the servlet and put it into Tomcat. When I fire up tomcat, it works well. But the servlet doesn't work, I get the following exception:

javax.servlet.ServletException: Wrapper cannot find servlet class FirstReportSendToBrowserServlet or a class it depends on     org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)     org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)     org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)     org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)     org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)     org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)     org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)     java.lang.Thread.run(Thread.java:619)  

But the servlet class has already been deployed in Tomcat, can somebody give hints?

回答1:

As the exception message hints, your servlet class is not in a package (normally the full qualified classname is shown there). You should always put the servlet class (and all other Java classes) in a package.

package com.parsifal; // <--- Here.  public class FirstReportSendToBrowserServlet extends HttpServlet {      // ...  } 

Classes in the default package are invisible to classes which reside in a package (such as Tomcat itself).



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!