permaculture playing cards*
The moose likes Tomcat and the fly likes java.lang.UnsupportedClassVersionError: Bad version number in .class file   (web app with Spring) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "java.lang.UnsupportedClassVersionError: Bad version number in .class file   (web app with Spring)" Watch "java.lang.UnsupportedClassVersionError: Bad version number in .class file   (web app with Spring)" New topic
Author

java.lang.UnsupportedClassVersionError: Bad version number in .class file (web app with Spring)

Menen Zwerky
Ranch Hand

Joined: Aug 06, 2010
Posts: 44
Hello everybody
I deployed a webapp under Tomcat but clicking one link in a web page of the application I encountered the following exception:

at java.lang.Thread.run(Unknown Source)
Mar 28, 2011 9:48:43 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet springapp
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1852)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:876)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1329)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1208)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.springframework.beans.factory.support.BeanDefinitionReaderUtils.createBeanDefinition(BeanDefinitionReaderUtils.java:60)
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinition(DefaultXmlBeanDefinitionParser.java:293)
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinition(DefaultXmlBeanDefinitionParser.java:261)
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinitions(DefaultXmlBeanDefinitionParser.java:184)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:170)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:129)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:144)
at org.springframework.context.support.AbstractXmlApplicationContext.refreshBeanFactory(AbstractXmlApplicationContext.java:79)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:249)
at org.springframework.web.context.support.XmlWebApplicationContext.refresh(XmlWebApplicationContext.java:131)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:281)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:228)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:199)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:103)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:791)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:127)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)

I tried to delete the work tomcat folder before restarting but I gained again the exception

Any suggestion?
Thanks a lot Menen

amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 512
Hello,
As far as I understand the java documentation, this happens when you compile a Java class with a higher version of JDK than the one in which you are trying to run that class file.

Regards,
Amit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.UnsupportedClassVersionError: Bad version number in .class file (web app with Spring)