• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help on following error

 
Anant Chandra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to run the Beer example from HFSJ and getting the form but when I am calling the Servlet then the following error is coming

http://localhost:8080/beerV1/SelectBeer.do


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.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.UnsupportedClassVersionError: com/example/web/BeerSelect (Unsupported major.minor version 49.0)
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:117)
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)


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


--------------------------------------------------------------------------------

Apache Tomcat/5.0.27

My DD is as follows
<?xml version="1.0" encoding="ISO-8859-1"?>



<web-app>

<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>


and my servlet code is as follows

package com.example.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BeerSelect extends HttpServlet {



public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("Beer Selection Advice<br>");
String c= req.getParameter("color");
out.println("<br>Got beer Color"+c);
Thread cq;

}
}



Can you help me
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anant,

I tried running your code. There was no error like you have mentioned when the code ran. However you would have to change the method doPost(..) to doGet(..)
in order to access it directly with the URL and I had removed the statement
Thread cq; in the servlet although it should not create a problem.
 
Dagbj�rn Nogva
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anant,

> java.lang.UnsupportedClassVersionError: com/example/web/BeerSelect (Unsupported major.minor version 49.0)

This looks like a Java version issue. Could it be that you have a mixup in the Java version used by your IDE, build.xml and/or servlet container. I remember I had a similar error some time ago. As far as I can recall, it was a conflict between Eclipse which compiled for Java 5, but the servlet container was WebLogic 8.1 running on Java 1.4.

HTH,
Dagbj�rn
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic