• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
pratik vyas
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to UseCodeTags when posting code.

it looks as if your class may be missing its package statement.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic