I have taking an existing, old, Java code base and changed one class. I have recompiled the code base in Java 1.5.0. I then successfully deploy this code on Tomcat.
To test my deployment, I send a message to my application and I hit an error with the class that I changed.
Error loading class [com.MyClass] for bean with name 'myClass' defined in ServletContext resource [/WEB-INF/ApplicationContext.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: (com/MyClass) bad major version at offset=6
I have checked the deployed Ear and War's manifest files and both have 1.5.0_22-b03. The version on the Tomcat instance is 1.5.0.
Can anyone tell me why I'm getting this error? The JDK running the application is the same version that the code was compiled on.
Strangely, the only class that has the error is the class I amended.
Seems as you have compiled your code with a higher Java version than 1.5. You should check if you have the right JRE installed (Window
-> Preferences
-> Java
-> Installed JREs
).
You should also check if the Compiler compliance level is set to 1.5 (Window
-> Preferences
-> Java
-> Compiler
).
I'm assuming you are using Eclipse...