servlet problems

B

boyScout

Hi guys, I'm learning servlet and jsp and when I encoutered this error
when i tried to access a servlet:
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:118)
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(Unknown Source)


root cause

java.lang.UnsupportedClassVersionError: com/jspbook/HelloWorld
(Unsupported major.minor version 49.0)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
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:118)
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(Unknown Source)



What kind of error is this? I can't undestand this error. Thanks
 
D

Danno

It is likely that the code was compiled in a higher version that what
the tomcat is running in.
 
L

Lew

boyScout said:
Hi guys, I'm learning servlet and jsp and when I encoutered this error
when i tried to access a servlet:
The server encountered an internal error () that prevented it from
fulfilling this request.

exception

javax.servlet.ServletException: Error allocating a servlet instance ....
root cause

java.lang.UnsupportedClassVersionError: com/jspbook/HelloWorld
(Unsupported major.minor version 49.0)

The version number, 49.0, refers to the class format of the JVM that built
your HelloWorld class file, which differs from what Tomcat expects. Presumably
Tomcat wants version 48.0.
What kind of error is this? I can't undestand this error. Thanks

It says that the application server (Tomcat) is running under one Java Virtual
Machine (JVM), but you built your servlet (and, presumably, associated WAR
with all its stuff) with a different one.

IIRC, class format 48.0 was Java 5 and 49.0 Java 6, but I am not sure and feel
too lazy to look it up just now.

The solution is to run Tomcat itself with the latest available Java (6). Those
that can read class format 49.0 can read 48.0, but not vice versa.

- Lew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top