• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat 5.5.17 problems - class not a servlet

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Let nothing stop you! Not even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic