简体   繁体   English

在1.6 JVM上运行的Jetty无法运行在Java 1.6上编译的webapp

[英]Jetty running on 1.6 JVM is unable to run webapp compiled on Java 1.6

I am trying to start very simple Java webapp on Jetty (v9.0) webserver. 我试图在Jetty(v9.0)webserver上启动非常简单的Java webapp。

Using maven I built and created the war and as can be see in the manifest file, I used Java 1.6u43 for compilation on OS X 使用maven我构建并创建了战争,并且可以在清单文件中看到,我在OS X上使用Java 1.6u43进行编译

Contents of META-INF/MANIFEST.MF META-INF / MANIFEST.MF的内容

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: irraju
Build-Jdk: 1.6.0_43

I am running Jetty on Ubuntu and as can be seen, I have slightly higher version of the java 1.6.0_45. 我在Ubuntu上运行Jetty,可以看出,我的java 1.6.0_45版本略高一些。 If java is backward compatible, my java application should run on jetty but it is failing with unsupported minor version 如果java是向后兼容的,我的java应用程序应该在jetty上运行,但它失败了,不支持的次要版本

root# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)

root# java -DDEBUG -jar start.jar 
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/eclipse/jetty/start/Main : 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)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.eclipse.jetty.start.Main. Program will exit.

Other people on the internet are facing this issue when they are trying to run Java 1.7 compiled applications on 1.6* JVMs. 当他们试图在1.6 * JVM上运行Java 1.7编译的应用程序时,互联网上的其他人正面临着这个问题。 I am unable to figure out why this is happening in my case where both the ENVs are 1.6* and deployment ENV has slightly higher version of JVM. 我无法弄清楚为什么在我的情况下发生这种情况,其中ENV都是1.6 *并且部署ENV具有略高版本的JVM。

If I deploy the application on Tomcat that is using java 1.6.0_45, it doesn't complain though and works fine. 如果我在使用java 1.6.0_45的Tomcat上部署应用程序,它不会抱怨并且工作正常。 Am I missing something very trivial here? 我在这里错过了一些非常微不足道的东西吗?

Jetty 9 requires to be ran with Java 7, according to this list of Jetty versions . 根据Jetty版本列表, Jetty 9需要使用Java 7运行。

You can try to compile Jetty 9 yourself using Java 6, but that will most likely not work (otherwise, the Jetty devs might've done that themselves as well). 您可以尝试使用Java 6自己编译Jetty 9,但这很可能不起作用(否则,Jetty开发人员也可能自己也这样做)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM