I am using Tomcat server with Eclipse and I am today running my first servlet.
But I got the following Exception :
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:164)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:732)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688)
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:1677)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:900)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1350)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1230)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:732)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688)
java.lang.Thread.run(Unknown Source)
note The full stack trace of the root cause is available in the T开发者_如何学Comcat logs.
Any ideas? Thanks in advance.
Update: I am using jdk1.5.0_16 for compiling the class and for Tomcat. I also included the servlet.jar
file to the project, could this be the cause of the problem?
The java version running tomcat is probably older than the code you want to execute. You should update the java version.
Your class is compiled with a different version of Java than the one used to run tomcat. Make sure they are the same.
精彩评论