File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Tomcat 5.5.17 problems - class not a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat 5.5.17 problems - class not a servlet" Watch "Tomcat 5.5.17 problems - class not a servlet" New topic
Author

Tomcat 5.5.17 problems - class not a servlet

Nick Barnes
Greenhorn

Joined: Oct 05, 2006
Posts: 2
Hi everyone,

I'm running Tomcat 5.5.17 in Linux enivronment and have deployed a webapp in a directory (myapp). I've set servlet mappings in web.xml and re-checked
that they are correct.

When I browse to myapp/index.jsp, it shows up correctly. However, when I continue using the servlet and the servlet tries to access myapp/measurements (defined in web.xml), I get the following error:

javax.servlet.ServletException: Class org.myapp.measureIt is not a Servlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)java.lang.Thread.run(Thread.java:595)

root cause

java.lang.ClassCastException: org.myapp.measureIt
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:595)


the Localhost log prints out the following:

INFO: Marking servlet measurements as unavailable
5.10.2006 9:53:53 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet measurements
5.10.2006 9:53:54 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet HTMLManager
java.lang.NoSuchMethodError: javax.servlet.ServletConfig.getServletName()Ljava/lang/String;
at org.apache.catalina.manager.ManagerServlet.init(ManagerServlet.java:447)
at javax.servlet.GenericServlet.init(GenericServlet.java:172)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:757)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)

The same happens with each and every one of the classes.


When I recompile the java files, it passes without errors, but I get the following warnings:

javax/servlet/http/HttpServlet.java:706: warning: [deprecation] setStatus(int,java.lang.String) in javax.servlet.http.HttpServletResponse has been deprecated
public void setStatus (int sc, String sm)
^
javax/servlet/http/HttpServlet.java:707: warning: [deprecation] setStatus(int,java.lang.String) in javax.servlet.http.HttpServletResponse has been deprecated
{ resp.setStatus (sc, sm); }

Does that have something to do with the errors? my custom servlets extend those javax.servlet classes.

I'd be extremely grateful for any help, am kind of a newbie with Tomcat and have been struggling with this for days now.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Thats odd alright. The following questions occur to me:
1. What version(s) of Java exist on this machine?
2. Have earlier Tomcat versions been running on this machine?
3. Are you sure the compiler is using the installed Tomcat servlet api jar?

Bill
That setStatus( int, String ) usage was deprecated in version 2.1 - thats pretty old, where did the code come from?
Nick Barnes
Greenhorn

Joined: Oct 05, 2006
Posts: 2
Originally posted by William Brogden:
Thats odd alright. The following questions occur to me:
1. What version(s) of Java exist on this machine?
2. Have earlier Tomcat versions been running on this machine?
3. Are you sure the compiler is using the installed Tomcat servlet api jar?

Bill


Thanks for the suggestions, they were right on. The problems were conflicting references to JDK (1.5.0_01 vs. 1.5.0_06) and CLASSPATH problems (there were duplicates and servlet-api.jar and jsp-api.jar were both missing). Now it's working fine.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Tomcat 5.5.17 problems - class not a servlet
 
Similar Threads
Serializable
File upload - Error 404 - servlet not available
error when run application on tomcat 5.5
Tomcat Server Error: java.lang.NoSuchMethodError
NotSerializableException