Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tomcat 7 encounters LifecycleException caused by java.lang.UnsupportedClassVersionError

 
Joseph Idol
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65113
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java 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.
 
Norbert Waage
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