简体   繁体   English

GlassFish服务器中是否存在java.lang.UnsupportedClassVersionError?

[英]java.lang.UnsupportedClassVersionError in GlassFish server?

I am trying to deploy a WAR file to GlassFish server. 我正在尝试将WAR文件部署到GlassFish服务器。 I am getting the following error: 我收到以下错误:

[#|2013-04-06T17:50:56.982-0430|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.org.glassfish.web.loader|_ThreadID=17;_ThreadName=Thread-2;|WEB9052: Unable to load class com.tugay.User, reason: java.lang.UnsupportedClassVersionError: WEB9032: Class com.tugay.User has unsupported major or minor version numbers, which are greater than those found in the Java Runtime Environment version 1.6.0_37|#] [#| 2013-04-06T17:50:56.982-0430 |警告| glassfish3.1.2 | javax.enterprise.system.container.web.org.glassfish.web.loader | _ThreadID = 17; _ThreadName = Thread-2; | WEB9052:无法加载类com.tugay.User,原因:java.lang.UnsupportedClassVersionError:WEB9032:类com.tugay.User不支持主要或次要版本号,这些版本号大于Java Runtime Environment 1.6版中的版本号。 0_37 |#]

Why is it complaining about my Java Version? 为什么抱怨我的Java版本? I have a @Named annotation on the class. 我在课程上有一个@Named注释。 Does Java 1.6.0_37 not support this annotation? Java 1.6.0_37是否不支持此注释?

package com.tugay.user;

import javax.faces.bean.SessionScoped;
import javax.inject.Named;
import java.io.Serializable;


@Named("userBean")
@SessionScoped
public class UserBean implements Serializable {

    private String userName;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
}

You've compiled the com.tugay.User source file using Java 7 or a newer version and attempt to run it on java 6. There is a Java 7 change in the .class format to allow better performance on non-statically-typed languages. 编译完com.tugay.User使用Java 7的源文件或更新的版本,并尝试基于java 6.有在一个Java 7运行改变它.class格式,以便在非静态类型语言中更好的性能。 See the official oracle documentation for more information. 有关更多信息,请参见正式的oracle文档

You can try to 您可以尝试

  • upgrade your production runtime to 7, 将您的生产运行时升级到7
  • use 1.6 to compile, or 使用1.6进行编译,或
  • use -source 1.6 -target 1.6 as modifiers to your build script 使用-source 1.6 -target 1.6作为构建脚本的修改器

There are further explanations in another question . 另一个问题中还有进一步的解释。

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

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