• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

tomcat 7 encounters LifecycleException caused by java.lang.UnsupportedClassVersionError

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i'm using apache tomcat 7 with jdk 1.7. i have so far been unsuccessful with running even one servlet.

i created my web application hierarchy as:

or
web application hierarchy

the java code is:


and the web.xml code is:


but i always get a 404 error message every time i run: http://localhost:8080/hello/sayhello

i then checked the stderr log and found that

Nov 7, 2011 4:11:42 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hello]]
.
.
.
Caused by: java.lang.UnsupportedClassVersionError: com/training/HelloServlet : Unsupported major.minor version 51.0 (unable to load class com.training.HelloServlet)



any thoughts as to how i may resolve this so that i can run my java servlets?
 
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's almost always a sign that you compiled the class with a deferent version of Java than Tomcat is using.
 
Sheriff
Posts: 21759
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Joseph Idol wrote:i'm using apache tomcat 7 with jdk 1.7. i have so far been unsuccessful with running even one servlet.

Caused by: java.lang.UnsupportedClassVersionError: com/training/HelloServlet : Unsupported major.minor version 51.0 (unable to load class com.training.HelloServlet)


That error indicates that the class has been compiled by a Java 7 compiler* but you're using an earlier JRE version. Make sure that Tomcat is really using your Java 7 installation, and not some other version.

* See here.
 
Greenhorn
Posts: 3
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:That's almost always a sign that you compiled the class with a deferent version of Java than Tomcat is using.


THANK YOU!
I was blowing my head out here...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!