• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat 5.5 JRE?

 
Benjamin Hundley
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a web application using jdk 1.6 and tomcat 6.0 at home and it worked fine. Then I wanted to put it online so I found a host site and uploaded my war. I got this:

java.lang.UnsupportedClassVersionError: Bad version number in .class file

This happened when it was trying to load my ServletContextListener. It looks like the host site was running Tomcat 5.5.17.

I then downloaded the java 1.5 jdk and tried to compile my servlet classes with that and then reployed it and I got the same thing. I searched through the tomcat documentation for a while and I couldn't find the JRE it was using to run my classes. What jdk do I need to use to compile my servlet classes for tomcat 5.5.17? Please don't tell me I have to rewrite my classes to be compatible with jdk 1.4. Thanks in advance.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do not need to re-write your classes to to work with 1.4 if you are using Tomcat 5.5. It requires at least java 1.5.

I'm guessing that something got flubbed up and the class file that was compiled under Java 6 was still up on the server.

Try again, making sure that none of the original class files are still on the server or loaded in Tomcat.


PS: You didn't need to download Java 1.5 to recompile.
javac has a -source switch that allows you to compile down to older versions.

Example:
javac -source 1.5 MyServlet.java
 
Benjamin Hundley
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. That worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic