• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while executing Beer Select example of head first java

 
Bipra De
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the following error after selecting a beer color in the form.html

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Class com.example.web.BeerSelect is not a Servlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Unknown Source)
root cause

java.lang.ClassCastException: com.example.web.BeerSelect cannot be cast to javax.servlet.Servlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Unknown Source)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.



I am using Tomcat6.0 and have deployed the files according to that mentioned in the book.Alos I have changed the <web-app> in the web.xml to
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">


Please help.Do I have to put any javax.servlet jar file in any folder in Tomcat?

Thanks in Advance.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2345
90
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Please help.Do I have to put any javax.servlet jar file in any folder in Tomcat?

Have a look at this document

Regards,
Frits
 
Tomasz Sochanski
Ranch Hand
Posts: 47
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your BeerSelect class implement javax.servlet.Servlet? (ie. by extending abstract class javax.servlet.http.HttpServlet)? Tomcat is servlet container - you don't need to add any addditional jars to handle servlets.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic