Koray Tugay
Koray Tugay

Reputation: 23780

java.lang.UnsupportedClassVersionError in GlassFish server?

I am trying to deploy a WAR file to GlassFish server. 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|#]

Why is it complaining about my Java Version? I have a @Named annotation on the class. Does Java 1.6.0_37 not support this annotation?

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;
    }
}

Upvotes: 1

Views: 6010

Answers (1)

HMM
HMM

Reputation: 3013

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. See the official oracle documentation for more information.

You can try to

  • upgrade your production runtime to 7,
  • use 1.6 to compile, or
  • use -source 1.6 -target 1.6 as modifiers to your build script

There are further explanations in another question.

Upvotes: 7

Related Questions