wood burning stoves*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Error while executing Beer Select example of head first java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Error while executing Beer Select example of head first java" Watch "Error while executing Beer Select example of head first java" New topic
Author

Error while executing Beer Select example of head first java

Bipra De
Greenhorn

Joined: Nov 06, 2011
Posts: 14
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.


Warm Regards,
Bipra De.
SCJP 1.6
SCWCD 1.5
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1529
    
  22

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

Joined: Jan 13, 2009
Posts: 47

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error while executing Beer Select example of head first java
 
Similar Threads
servlet generating big xml give me a java.lang.IllegalStateException
update query
connectionURL to SQL Server 2005
Not authenticating the user
Tomcat in Eclipse File Write Permissions