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.Http1开发者_StackOverflow1Processor.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?
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).
精彩评论