Tomcat 6 和 Tomcat 5.5 不兼容的错误
我使用 Tomcat 6 开发了一个 Tomcat 应用程序进行测试。 我现在已将其部署到 Tomcat 5.5 - 当我调用 servlet 时,我收到一个错误,这对我来说没有多大意义。 有谁知道导致此错误的原因。
异常
javax.servlet.ServletException:分配 servlet 实例时出错 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(Thread.java:595) 根本原因
java.lang.UnsupportedClassVersionError:.class 文件中的版本号错误 java.lang.ClassLoader.defineClass1(本机方法) java.lang.ClassLoader.defineClass(ClassLoader.java:620) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) 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) java.security.AccessController.doPrivileged(本机方法) 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(Thread.java:595)
I developed a Tomcat application using Tomcat 6 for testing. I have now deployed it to Tomcat 5.5 - when I invoke the servlet I get an error which doesn't make much sense to me. Does anyone know what causes this error.
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(Thread.java:595)
root cause
java.lang.UnsupportedClassVersionError: Bad version number in .class file
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
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)
java.security.AccessController.doPrivileged(Native Method)
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(Thread.java:595)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这与tomcat无关。 该错误是由于.class文件版本差异引起的。
最有可能的是,您已经使用 Java6 编译了一个 .class 文件,并尝试在 Java5 上运行它。
解决方案是要么在较新版本的 Java 上运行 tomcat5.5,要么只是重新编译。
This has nothing to do with tomcat. The error is caused by .class file version difference.
Most likely, you've compiled a .class file with Java6, and have tried to run it on Java5.
The solution is to either run tomcat5.5 on the newer version of Java, or just recompile.
我也刚刚遇到过这个。 问题实际上是在Tomcat 6中编译的jsps。所以当我切换到Tomcat 5时,这些编译的jsps就是问题的原因。 解决方法是清除工作目录。
但是,只有当您指定由 Tomcat 6 和 5 共享的 CATALINA_BASE 时,这才会出现问题。
I just ran across this too. The problem was actually jsps that had been compiled in Tomcat 6. So when I switched to Tomcat 5, these compiled jsps were the cause of the problem. The solution is to clear the work directory.
However, this would only be the problem if you are specifying CATALINA_BASE which was shared by Tomcat 6 and 5.