问题分析
com.ibm.ws.webcontainer.annotation.WASAnnotationHelpercollectClasses unable to instantiate class
java.lang.UnsupportedClassVersionError:JVMCFRE003bad major version;class=com/soa/listener/SpringContextLoaderListener, offset=6
at java.lang.ClassLoader.defineClassImpl(NativeMethod) at java.lang.ClassLoader.defineClass(ClassLoader.java:28
//解决方案与方法如下:
http://stackoverflow.com/questions/14926402/unsupportedclassversionerror-jvmcfre003-bad-major-version-in-websphere-as-7
WebSphere Application Server V7 does supportJava Platform, Standard Edition (Java SE) 6(seeSpecifications and API documentationin the Network Deployment (All operating systems), Version 7.0 Information Center) and it's sincethe release V8.5 when Java 7 has been supported. I couldn't find the Java 6 SDK documentation, and could only consultIBM JVM MessagesinJava 7 Windows documentation. Alas, I couldn't find the error message in the documentation either. Sincejava.lang.UnsupportedClassVersionErroris"Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported.", you ran into an issue of building the application with more recent version of Java than the one supported by the runtime environment, i.e. WebSphere Application Server 7.0. I may be mistaken, but I think thatoffset=6in the message is to let you know what position caused the incompatibility issue to occur. It's irrelevant for you, for me, and for many other people, but some might find it useful, esp. when they generate bytecode themselves. Run theversionInfocommand to find out about theInstalled Featuresof WebSphere Application Server V7, e.g.
| |||
In this Eclipse Preferences panel you can change the compiler compatibility from 1.7 to 1.6. This solved the similar message I was getting. For Eclipse, it is under: Preferences -> Java -> Compiler: 'Compiler compliance level' | |||
This error can occur if you project is compiling with JDK 1.6 and you have dependencies compiled with Java 7. | |||||
|
You should also make sure you have set appropriate Project Facets Java version. Module Properties -> Project Facets -> Java 1.6 should be checked | |||
I was getting this error in websphere 8.5: java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=com/xxx/Whatever, offset=6 I had my project JDK level set at 1.7 in eclipse and was8 by default runs on JDK 1.6 so there was a clash. I had to install the optional SDK 1.7 to my websphere server and then the problem went away. I guess I could have also set my project level down to 1.6 in eclipse but I wanted to code to 1.7. | |||
I was getting the same error. In the Project Facets of my Java project, the Java compile level was set to 1.7 whereas the WebSphere Application Server v7.0 had a Runtime Composition of JRE v1.6; setting the Java compile level to 1.6 in Project Facets got rid of the error. I did not have to change the Compiler compliance level though, it's still 1.7. Hope this helps! | |||
At firstyou should check major version of compiled problematic WAS7 uses Java 6 (as said Jacek), and Java 6 uses major version 50, soyou have to compile your project with Java 6. How to set proper version of Java compiler depends on your IDE (e.g. Eclipse, IntelliJ) or build tool (e.g. Maven, Ant). |
-source
and-target
options ofjavac
.– Jacek Laskowski Apr 2 '13 at 12:55