all that is technology

UnsupportedClassVersionError unsupported major.minor version 51.0


For J2EE webapps, when development environment is different from production environment, deploying could be tedious.

One such issue I encountered is the difference in JDK version. My development machine have latest JDK1.7 whereas my production servers have JDK1.6. When deploying the war on this server, I was getting the following exception catpured in catalina.out

Caused by: java.lang.UnsupportedClassVersionError: com/arundhaj/controller/TestController : Unsupported major.minor version 51.0 (unable to load class com.arundhaj.controller.TestController)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(
        at org.apache.catalina.loader.WebappClassLoader.findClass(
        at org.apache.catalina.loader.WebappClassLoader.loadClass(
        at org.apache.catalina.loader.WebappClassLoader.loadClass(
        at org.springframework.util.ClassUtils.forName(
        ... 23 more
Jan 8, 2013 9:39:45 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart

To get rid of this, we need to tell eclipse to build the war for production servers' target. I am using maven, hence, in maven-compiler-plugin set target to 1.6 as