Tomcat6 and JRE7 compatibility issue. Unsupported major.minor version 51.0

时光总嘲笑我的痴心妄想 提交于 2019-12-11 11:38:34

问题


I have a web app compiled with JRE7 and now i'd like to run it on Tomcat6. When I launch my app I see exception in the logs:

Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) 

This exception comes from the class that implements ServletContextListener.

Does that mean I have to use Tomcat7 for code compiled with JRE7? Is there a workaround? Any information will be valuable.


回答1:


You're attempting to run Java 7 bytecode with a Java 6. You need to deploy it to Tomcat 7 or recompile using JDK 1.6. Check what JRE your Tomcat uses. I guess it's Java 6 JVM.




回答2:


You can find out the server information through its status page:

{running-tomcat-url}/manager/status

On that page you can see the version of Java on which your Tomcat runs



来源:https://stackoverflow.com/questions/17478093/tomcat6-and-jre7-compatibility-issue-unsupported-major-minor-version-51-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!