• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet is not running on tomcat

 
Kumar Nitesh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys this is nitesh having the problem in running my first servlet program for simlply write Hello world on tomcate i have set my classpath=tomcatehome\Tomcat 5.0\common\lib\servlet-api.jar.
and paht=C:\Apache\bin;C:\Java\jdk1.5.0_05\bin;
My source file is-import java.io.*;

xml file is
<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/com</url-pattern>
</servlet-mapping>
</web-app>
now server give 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: Wrapper cannot find servlet class HelloWorldExample or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Unknown Source)

root cause
java.lang.ClassNotFoundException: HelloWorldExample
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Unknown Source)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28
Please give me the solution what is the problem in this servlet program i am very in tension due to this.



[BPSouther: Added code tags]
[ August 23, 2007: Message edited by: Ben Souther ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you putting the class file ?
And how are you deploying the web application ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


ALL classes used in servlets should be in a package and placed in the WEB-INF/classes directory according to the package. If you don't you get the "cannot find the class" error.

Bill
 
krishnamoorthy kitcha
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi kumar,

where is your location to create your servlet ?

Suppose if you are using Tomcat Server , the root directory is webapps\root\yourservletname ?

check your context path in your client file ? or else

ping like this in your browser

http://localhost:8080/contextname or /servletmapping varible followed by the parameter .
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to answering Raul's questions please post the URL that you're using when trying to access your servlet from your browser.

Also, it is important that you package all of your Java classes when writing web applications. There are times when unpackaged classes can be found and cases where they can not. When starting out, you don't need to concern yourself with understanding this. Just package everything.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15711
73
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javax.servlet.ServletException: Wrapper cannot find servlet class HelloWorldExample or a class it depends on

Is your servlet class named HelloWorld or HelloWorldExample? Your code looks like it's called HelloWorld, but the error message indicates that you've used the name HelloWorldExample somewhere.

Make sure that you have the class name and deployment descriptor correct.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!