• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

HTTP status 500

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i click submit button on form.html page it gives 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: Error allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
java.lang.Thread.run(Unknown Source)

root cause

java.lang.NoClassDefFoundError: com/example/web/BeerSelect (wrong name: BeerSelect)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1960)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:933)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1405)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
java.lang.Thread.run(Unknown Source)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.33 logs.
Apache Tomcat/5.5.33

my form.html code is as below:

<html>
<head>
BEER
</head>

<body>
hello <p>
<form method="post" action="SelectBeer.do">
color:
<select name="color" size="1">
<option value="light">light</option>
<option value="blue">blue</option>
<option value="red">red</option>

</select>
<center>
<input type="Submit">
</center>

</form>


</body>
</html>

my servlet code BeerSelect.java is as follows

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 <br>");
out.println("<br>GOT BEER COLOR "+ request.getParameter("color"));

}

}

my dd code is as below:
<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 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>


for deployment i have put my BeerSelect.class file in C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\BEER-v1\WEB-INF\classes\com\example\web directory,and kept DD file in C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\BEER-v1\WEB-INF directory.also form.html file in C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\BEER-v1 directory.

please can anyone help???
 
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Abhinav!

You don't appear to have a "package" statement at the beginning of your BeerServlet.java file. Without it, the Java compiler would normally expect to look in the default package, but you do apparently have the right source directory structure for com.example.web.BeerSelect.java. So the Java runtime has found a mismatch between your file organization and your (implicit) package declaration and it's unhappy.

BTW, there's a "Code" button on the Ranch Editor that can be used to insert code tags into your message. Using code tags makes java code and XML easier to read.
 
Abhinav Kumar Mishra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Welcome to the JavaRanch, Abhinav!

You don't appear to have a "package" statement at the beginning of your BeerServlet.java file. Without it, the Java compiler would normally expect to look in the default package, but you do apparently have the right source directory structure for com.example.web.BeerSelect.java. So the Java runtime has found a mismatch between your file organization and your (implicit) package declaration and it's unhappy.

BTW, there's a "Code" button on the Ranch Editor that can be used to insert code tags into your message. Using code tags makes java code and XML easier to read.





Thanks for reply soon. I have got my error fixed.
 
Did you just should on me? You should read this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic