aspose file tools*
The moose likes Servlets and the fly likes Errror in deploying servlet: wrong name: TestServlet 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 "Errror in deploying servlet: wrong name: TestServlet" Watch "Errror in deploying servlet: wrong name: TestServlet" New topic
Author

Errror in deploying servlet: wrong name: TestServlet

akshay ranganath
Greenhorn

Joined: Dec 26, 2004
Posts: 4
Hi,

I am learning Servlets. I created a servlet called TestServlet in a class akshay.

The URL for the servlet is http://localhost:8080/Test/testServlet?name=aaa&password=aaa

The deployment structure looks like:
webapps/WEB-INF/classes/akshay/TestServlet.class

The Web.xml has the following lines:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "file:C:\Java\web-app_2_3.dtd">

<web-app>
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>akshay.TestServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/testServlet</url-pattern>
</servlet-mapping>
</web-app>

I got this error:

exception

javax.servlet.ServletException: Error allocating a servlet instance
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(Thread.java:534)

root cause

java.lang.NoClassDefFoundError: akshay/TestServlet (wrong name: TestServlet)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:539)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
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(Thread.java:534)

Could you please help me out in resolving this?

Thanks,
Akshay
pawank gupta
Ranch Hand

Joined: Jun 07, 2006
Posts: 34
akshay is ur class of ur package. if it is a class then how could u run the servlet. a servlet is independent class
Gadi Reddy
Greenhorn

Joined: Jan 10, 2006
Posts: 21
Check your classs name and servlet-name.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

This is a problem with the way you have set up your package and compiled the class. Make sure the class is declared 'package akshay;' at the start, and make sure it is compiled as askay/TestServlet.java and not just TestServlet.java
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

pawank gupta
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for posting here. You can find the list in our
FAQ section here. In particular, please see UseRealWords.

Abbreviations such as "ur" instead of "you are" or "you're" confound lnaguage translation software making it difficult or impossible for our non-English speaking members to read your posts.

Again, welcome to JavaRanch and thank you for helping out.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
akshay ranganath
Greenhorn

Joined: Dec 26, 2004
Posts: 4
Thanks a lot for the help...
The problem turned out to be something else altogether - I was using eclipse for development/compiling. There seems to be a strange error in it.

Unless I save a file and then re-compile, it is not detecting the changes, even though "Build Automatically" option was set. When I started to this, the problem got resolved.
 
wood burning stoves
 
subject: Errror in deploying servlet: wrong name: TestServlet