ERROR starting the java project with Tomcat

Asked

Viewed 125 times

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 not Currently available. Apache Tomcat/6.0.37

  • I solved the problem. It was the version of Tomcat

  • jdk1.6 funnel on Tomcat 7

1 answer

1


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

For example, the WAR classes have been compiled with Java 7 and Tomcat runs in Java 6. Now, Java 6 cannot understand version 7 classes, although the opposite happens.

See the documentation.

The solution in this case may be:

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

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

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

This is not a rare problem.

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

javap -verbose MinhaClasse

Browser other questions tagged

You are not signed in. Login or sign up in order to post.