Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

first servlet program from Headfirst book

 
sarvesh dikonda
Ranch Hand
Posts: 58
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My HTML file is as follows-


Below is DD .xml file -



Below is servlet code -



I have followed the same instructions as in the book.



On running the above command on the command prompt i successfully got the CoffeeSelect.class file. But if someone can verify the above command and also help me understand the following part of the above command "C:\Tomcat 5.25\common\lib\servlet-api.jar";classes;. if it is right!

My Development Environment-

For HTML file is E:\MyProjects\coffeeV1\web\form.html
For DD file is E:\MyProjects\coffeeV1\etc\web.xml
For servlet file is E:\MyProjects\coffeeV1\src\com\example\web\CoffeeSelect.java
For servlet .class file is E:\MyProjects\coffeeV1\classes\com\example\web\CoffeeSelect.class

My Deployment Environment-

For HTML file is C:\Tomcat 5.25\webapps\Coffee-v1\form.html
For DD file is C:\Tomcat 5.25\webapps\Coffee-v1\WEB-INF\web.xml
For servlet .class file is C:\Tomcat 5.25\webapps\Coffee-v1\WEB-INF\classes\com\example\web\CoffeeSelect.class


On running the following URL on the Google Chrome browser -
http://localhost:8080/Coffee-v1/form.html
the form gets displayed but when i click the Submit button
i get the following error-
HTTP Status 500 -

type Exception report

message

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

exception

javax.servlet.ServletException: Error instantiating servlet class com.example.web.CoffeeSelect
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
java.lang.Thread.run(Thread.java:619)
root cause

java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.example.web.CoffeeSelect with modifiers ""
sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
java.lang.Class.newInstance0(Class.java:349)
java.lang.Class.newInstance(Class.java:308)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
java.lang.Thread.run(Thread.java:619)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.

Apache Tomcat/5.5.25


And if i reload the page i get -

HTTP Status 404 - Servlet Ch3 Coffee is not available

type Status report

message Servlet Ch3 Coffee is not available

description The requested resource (Servlet Ch3 Coffee is not available) is not available.

Apache Tomcat/5.5.25


One more thing guys do i have to download the javax package? But i did not find such reference in the book. I also tried doing that but still i cannot get he above error out of my sight!

Hey friends and all you knowledgeable people kindly help me out with my first servlet program and help me out from getting discouraged and loose interest over this as i have been doing various modifications but none seems to work out. Help me guys!
 
sarvesh dikonda
Ranch Hand
Posts: 58
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please someone reply ! Curiously, waiting for the help.
 
Antriksh jain
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sarvesh dikonda wrote:Please someone reply ! Curiously, waiting for the help.


Have you tried cleaning your Tomcat server? :

1 clicking on the Tomcat server at the server window.
1. Clean Tomcat work directory.
2. Clean Tomcat.
3. Clean project.
4. Refresh project.
 
T Mishra
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.example.web.CoffeeSelect with modifiers ""

your class is defined with a default access modifier.
class CoffeeSelect extends HttpServlet

Try changing it to public.
 
sarvesh dikonda
Ranch Hand
Posts: 58
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Superb guys! I am happy! Thank you both T Mishra and Antriksh jain for your precious suggestions. Now i can move ahead happily! This is why i love this forum so much. Keep up the the good work guys! God bless!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic