aspose file tools*
The moose likes Servlets and the fly likes ServletException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletException " Watch "ServletException " New topic
Author

ServletException

Rukmini Nagalla
Greenhorn

Joined: Apr 29, 2005
Posts: 11
Hi,
I am using tomcat 5.5 and I copied the HelloWorldExample servlet from servlet-examples directory into my webapp directory.I have added the following statements in web.xml.
<servlet>
<servlet-name>HelloWorldExample</servlet-name>
<servlet-class>/WEB-INF/classes/HelloWorldExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldExample</servlet-name>
<url-pattern>/HelloWorldExample</url-pattern>
</servlet-mapping>
when I run the servlet I get an exception saying:
javax.servlet.ServletException: Wrapper cannot find servlet class /WEB-INF/classes/HelloWorldExample or a class it depends on.
Any help is appreciated.

Thanks,
Mini
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

"Mini",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

Place your servlet in a package other than the default.

Also, your <servlet-class> declaration should be the fully-qualified name of the class, not its file path.
[ April 29, 2005: Message edited by: Bear Bibeault ]
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081


<servlet-class>/WEB-INF/classes/HelloWorldExample</servlet-class>


did you try with

<servlet-class>HelloWorldExample</servlet-class>

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Rukmini Nagalla
Greenhorn

Joined: Apr 29, 2005
Posts: 11
Thanks Shailesh.I tried your suggestion now I get this error
java.util.MissingResourceException: Can't find bundle for base name LocalStrings, locale en_US
Rukmini Nagalla
Greenhorn

Joined: Apr 29, 2005
Posts: 11
HelloWorldExample is not in a package by default I believe. There is no package statement in it'z source file.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by Rukmini Nagalla:
There is no package statement in it'z source file.


So you package it

is there any stacktrace , any line number of error ?
Put the code here

Shailesh
Rukmini Nagalla
Greenhorn

Joined: Apr 29, 2005
Posts: 11
I didn't package it.AS it is shipped with tomcat itself, I wondered it should work the same way in my webapps too.I just checked the source code.
Here is the full stack trace from log file:

SEVERE: Servlet.service() for servlet HelloWorldExample threw exception
java.util.MissingResourceException: Can't find bundle for base name LocalStrings, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at HelloWorldExample.doGet(HelloWorldExample.java:39)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Rukmini Nagalla
Greenhorn

Joined: Apr 29, 2005
Posts: 11
Thanks Shailesh,I got it.I imported the other string classes and it worked.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you're looking for a quick way to get a hello world app up and running, you can grab SimpleServlet from http://simple.souther.us.

It's a war file so all you need to do is drop the file in your Tomcat/webapps directory and it will run.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

glad to know that you solved it yourself

Shailesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletException