我已经使用Java 7 JRE_HOME在Ubuntu 12上设置了我的Tomcat 7 :
$ /usr/share/tomcat7/bin/version.sh
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME: /usr/lib/jvm/java-7-openjdk-i386
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.26
Server built: Apr 11 2012 12:24:08
Server number: 7.0.26.0
OS Name: Linux
OS Version: 3.2.0-24-generic-pae
Architecture: i386
JVM Version: 1.7.0_03-b147
JVM Vendor: Oracle Corporation
但是在部署一个编译为 1.7 的简单 JSF 应用程序时,Tomcat 会抱怨
SEVERE: Critical error during deployment:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! java.util.concurrent.ExecutionException: java.lang.UnsupportedClassVersionError: com/corejsf/UserBean : Unsupported major.minor version 51.0 (unable to load class com.corejsf.UserBean)
当我将 Ant build.xml 更改为编译为“1.6”时,应用程序部署良好。这种与 Java 7 的不兼容是否可以预料?关于 Tomcat 7 / Java 7 兼容性有一个 6 个月大的相关问题,但那里的答案似乎表明支持 Java 7。