Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Need Help with Simple Servlet (my first servlet)

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm attempting to get a simple servlet running on Tomcat 6. I created my html code, java code, etc in Eclipse 3.3.2. I exported the code to a TestServlet.war file and put it into the Tomcat root\webapps folder. I am able to bring up the html page (http://localhost/TestServlet/default.html) and enter some text. When I submit the form I get a 404 error in the browser:
The requested resource (/servlet/ExampServlet) is not available.

This is the HTML code in my default.html file:



This is my servlet code:



This is my web.xml:



The tomcat logs indicate the following problem/stack trace:
Jan 2, 2009 4:00:40 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet org.apache.catalina.INVOKER.ExampServlet as unavailable
Jan 2, 2009 4:00:40 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@15ee671
ExampServlet
java.lang.ClassNotFoundException: ExampServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1083)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:361)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:170)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)
Jan 2, 2009 4:00:40 PM org.apache.catalina.core.ApplicationContext log
SEVERE: invoker: Cannot allocate servlet instance for path /servlet/ExampServlet
javax.servlet.ServletException: Wrapper cannot find servlet class ExampServlet or a class it depends on
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:361)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:170)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: ExampServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1083)
... 17 more


I've been researching this all day and I'm not getting anywhere. Does anyone have any ideas on what could be causing the problem? What I can check to try to get this working? Thanks for any and all suggestions.

 
Marshal
Posts: 67463
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does your action start with "/servlet"? And why doesn't it match your mapping?
 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change the URL in the form action to TestServlet. The mapping is thru TestServlet not ExampServlet.
 
Deepa Korecherla
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh did not check the /* after the TestServlet....thought you were referring to /TestServlet
 
K DeLucia
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got it working now. I wasn't completely understanding how all the pieces fit together (obviously) but you gave me a shove in the right direction. Now to get it to actually do something worthwhile . . .

Thanks again!
 
reply
    Bookmark Topic Watch Topic
  • New Topic