File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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

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 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 Source)
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 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.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinition(
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinition(
at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinitions(
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(
at org.springframework.web.servlet.FrameworkServlet.initServletBean(
at org.springframework.web.servlet.HttpServletBean.init(
at javax.servlet.GenericServlet.init(
at org.apache.catalina.core.StandardWrapper.loadServlet(
at org.apache.catalina.core.StandardWrapper.allocate(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
at org.apache.tomcat.util.threads.ThreadPool$
at 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: 544
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.

I agree. Here's the link:
subject: java.lang.UnsupportedClassVersionError: Bad version number in .class file (web app with Spring)
It's not a secret anymore!