my dog learned polymorphism*
The moose likes Tomcat and the fly likes javax.servlet.ServletException: Error allocating a servlet instance with Tomcat 6.0.20 on windows 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "javax.servlet.ServletException: Error allocating a servlet instance with Tomcat 6.0.20 on windows 7" Watch "javax.servlet.ServletException: Error allocating a servlet instance with Tomcat 6.0.20 on windows 7" New topic
Author

javax.servlet.ServletException: Error allocating a servlet instance with Tomcat 6.0.20 on windows 7

pratik vyas
Greenhorn

Joined: Jul 03, 2008
Posts: 2


Getting Following error while loading servlet using Submit Button on Html page .

My Servlet class

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice
");
String c= request.getParameter("color");
out.println("
Got Beer Color"+c);

}
}



web.xml

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name> Ch3 Beer </servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name> Ch3 Beer </servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>

</web-app>

Error

javax.servlet.ServletException: Error allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:574)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1527)
java.lang.Thread.run(Unknown Source)

java.lang.NoClassDefFoundError: com/example/web/BeerSelect (wrong name: BeerSelect)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(Unknown Source)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1850)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:890)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1354)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:574)
org.apache.tomcat.util.net.AprEndpoint$Wo



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61299
    
  66

Please be sure to UseCodeTags when posting code.

it looks as if your class may be missing its package statement.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: javax.servlet.ServletException: Error allocating a servlet instance with Tomcat 6.0.20 on windows 7