ERROR when starting the java project with tomcat

1

I put the project war in the webapp folder but the application does not appear in the browser gives this error:

SEVERE: Error deploying web application archive webrun.war
java.lang.UnsupportedClassVersionError: Bad version number in .class file(unable to load class wfr.web.WebrunContextListener)


No navegador:

HTTP Status 503 - This application is not currently available

type Status report

message This application is not currently available

description The requested service is currently not available. Apache Tomcat / 6.0.37

    
asked by anonymous 07.04.2016 / 15:03

1 answer

1

Conform already mentioned in comments, the error is yes by attempting to load a compiled class with a different version of Java.

For example, WAR classes were compiled with Java 7 and Tomcat runs in Java 6. However, Java 6 can not understand version 7 classes, although the opposite happens.

See the documentation .

The solution, in this case, can be:

  • Compile the classes with the same version where they will be executed
  • Or run with the same version as they were compiled

If I understood correctly, the AP solution was that of the second item.

Furthermore, unlike what has been mentioned, WAR files and correlates are not agnostic about the Java version. It's true that they are ZIP files, but in 99.9% of cases they have compiled classes inside using a specific JDK.

This is not a rare problem.

The way to make sure is to extract the WAR and look in the folder WEB-INF/classes the version of the classes. This can be done with the javap command, for example:

javap -verbose MinhaClasse
    
08.04.2016 / 01:47