aspose file tools*
The moose likes Beginning Java and the fly likes Http status 500 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Http status 500" Watch "Http status 500" New topic
Author

Http status 500

rakesh kadulkar
Ranch Hand

Joined: Jul 24, 2008
Posts: 115
Hi i am referring the HFS servlets and jsp..
My question is that i have done the example in the 3rd chapter successfully on one pc but unable to do it on the other pc with the same softwares i.e.tomcat 5.5 and jdk 1.6.0 ..(on windows)
The error i m gating is for the first version of the servlet...
Though the browser is showing the form.html when i select the color and hit submit the error i get is:

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:874)
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.UnsupportedClassVersionError: Bad version number in .class file
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:1853)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:875)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1330)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1209)
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:874)
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.26 logs.

What is the cause and the solution ?

My code is :
For servlet:
package com.example.web;

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");
String c=request.getParameter("color");
PrintWriter out=response.getWriter();
out.println("Selected Beer Color" + c);
}
}


Rakesh Kadulkar
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


java.lang.UnsupportedClassVersionError: Bad version number in .class file

It looks like you have compiled your code with one version of Java and are trying to run it with another earlier version. Check which versions of the JDK you use to compile your code and run your servlet container.
[ August 08, 2008: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
rakesh kadulkar
Ranch Hand

Joined: Jul 24, 2008
Posts: 115
no friend i m using the same code compiled with the same version as i have installed jdk 1.6.0 today itsele and doing every thing now...
So no chances of happening what you said

Check if there is any other prblem and let me know immediately.
Thanks in advance
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Originally posted by rakesh kadulkar:
no friend i m using the same code compiled with the same version as i have installed jdk 1.6.0 today itsele and doing every thing now...
So no chances of happening what you said


Well, I'm afraid that is what is happening. Classes get their version number from the compiler, so your code is definitely being compiled by a version of the JDK that is not the same as the version you are running your servlet container in.

Check your build path. Check how you start your servlet container. How do both these things find the version of Java to use?
Ragav Baskaran
Ranch Hand

Joined: Nov 04, 2007
Posts: 36
Try putting an echo statement for your JAVA_HOME variable.

echo %JAVA_HOME%

Thanks.
rakesh kadulkar
Ranch Hand

Joined: Jul 24, 2008
Posts: 115
dude its not working i tried
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42939
    
  68
What have you tried? What is not working? TellTheDetails
rakesh kadulkar
Ranch Hand

Joined: Jul 24, 2008
Posts: 115
i tried this:
Try putting an echo statement for your JAVA_HOME variable.

echo %JAVA_HOME%

But doesnt worked..The error persists
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Here is another root. It looks like you are using Tomcat. In Tomcat's bin directory there should be an executable with a w in the name, like tomcat6w.exe. Use that to get at the Tomcat service monitor. Select the Java tab and it will tell you what Java Virtual Machine is being used to run the servlet container in.

Press the [...] button next to the JVM path and select the one that you used to compile your code.

If you have a different server or start Tomcat through an IDE you will have to read their documentation to figure out how to change the JVM used by the server.


Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Http status 500