Very wired problem:
I tried to impot to eclipse an application that I usually develop on another machine.
After importing configuring and running most of the application run fine apart from one annoying
servlet that whenever I call it I get the error:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
java.lang.ClassLoader.defineClass1(Native Method)
Only this server. I know that normally
java throws this errro as a result of compiling on one version and running on lower version, but this is not the situation. The rest of the servlets works just fine. So I thought, why not creating in Eclipse a new servlet call it in another name, copy to it the same content like the problematic serlet and bind the url
pattern to the new servlet.
It worked at first only when performing GET method to the new Servlet. on Post I got
HTTP error 405. but then after a few runs I got back to the state that after every request GET or POST I recieve the error:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
java.lang.ClassLoader.defineClass1(Native Method)
with the new Servlet class.
I really don't unsderstand what is going on. I tried to run it on
Tomcat outside eclipse environment and got the same behavior.
I admit that on the original mahcine where the application work fine I run it on
JDK 1.6 and
Tomcat 6 and in the new machine it's
JDK 1.5 and
Tomcat 5.5 but I cleaned and built all the classes on the new environment again, just used the same sources. In addition that doesn't explain why it works fine in 90% of the serlets and why the same servlet sometimes works and sometimes not.
Has anyone has a vague idea what could have caused it?