wood burning stoves 2.0*
The moose likes Tomcat and the fly likes tomcat 7 encounters LifecycleException caused by java.lang.UnsupportedClassVersionError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "tomcat 7 encounters LifecycleException caused by java.lang.UnsupportedClassVersionError" Watch "tomcat 7 encounters LifecycleException caused by java.lang.UnsupportedClassVersionError" New topic
Author

tomcat 7 encounters LifecycleException caused by java.lang.UnsupportedClassVersionError

Joseph Idol
Greenhorn

Joined: Nov 07, 2011
Posts: 1

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?
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Try to access it by: http://localhost:8080/myWebApp/sayhello


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19685
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Norbert Waage
Greenhorn

Joined: Jun 08, 2012
Posts: 3

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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tomcat 7 encounters LifecycleException caused by java.lang.UnsupportedClassVersionError