Environment has JRE 7 but getting Unsupported major.minor version 51.0

399 Views Asked by At

I am working on a Hadoop project which is deployed in test and production environments. While everything works fine in the test environment, the same code / build fails in the production environment with the below error :

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/package/vo/MyClassName : 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) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:95) at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:107) at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31) at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:50) at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:120) at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31) at sun.reflect.generics.repository.FieldRepository.getGenericType(FieldRepository.java:67) at java.lang.reflect.Field.getGenericType(Field.java:223) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:117) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) at com.google.gson.Gson.getAdapter(Gson.java:356) at com.google.gson.Gson.fromJson(Gson.java:802) at com.google.gson.Gson.fromJson(Gson.java:768) at com.google.gson.Gson.fromJson(Gson.java:717) at com.google.gson.Gson.fromJson(Gson.java:689)

I understand this should be due to version mismatch between java version used while compiling the class and java version used to run the same.

But I check this and see both my test and production environments use jre 7 and I believe version 51 should be compatible with this.

Test environment

]$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

Production environment

]$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

Hadoop version used in test environment : Hadoop 2.6.0.2.2.9.0-3393 Hadoop version used in production environment : Hadoop 2.4.0.2.1.15.3-7

The above class is run using the below command in a shell script and this is where the error occurs.

**java -cp $ALL_JARS com.package.hello.hadoop.udf.GetCount**

where ALL_JARS is a ':' delimited list of jar files, one of which contains the above class GetCount and another contains the class for which the error is shown : com/package/vo/MyClassName

May I know what could be going wrong here and that too only in the production environment which also has the same java version as the test environment

0

There are 0 best solutions below