arundhaj

regression towards the datascience

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(WebappClassLoader.java:2908)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
        ... 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

<configuration>
    <source>1.6</source>
    <target>1.6</target>
</configuration>

Comments