• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting error: Bad version number in .class file

 
Mayank Kalbhor
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Need some help. I created a simple servlet from VTC tutorials. The problem i compile the servlet and put it in exact directories mentioned in the tutorial but after deployment of the app(war file) in j2ee web container i am getting this error.

java.lang.UnsupportedClassVersionError: Bad version number in .class file
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1798)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:910)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1375)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1239)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)


after googling I came to know this happens due to conflicting versions of java while compiling and running. I am using "C:\Program Files\Java\jdk1.6.0_21" as JDK and "j2eesdk-1_4_03-windows" as the container. Can you please how can i downgrade the JDK path in EV.? How can i match the versions so that i am able to compile.

Thank you in advance.

Mayank kalbhor
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
j2eesdk-1_4_03 is way, WAY, obsolete - time to get rid of it.

If it's just servlets and JSPs you're interested in use Tomcat 6 (or 7) as the container, and make sure it also uses Java 6 (or jdk1.6, as it's sometimes called).

As an aside, in the future please UseAMeaningfulSubjectLine.
 
Mayank Kalbhor
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you ulf for a quick response. I am downloading Tomcat 7 now.

Thanks a lot...


Mayank
 
Arvind Gangwar
Ranch Hand
Posts: 37
MyEclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Ulf,
I am also new one , but as i know, you are eight, that your problem is because of conflicting versions of java.
So you should try ...this as..
1-
You should change the path variable in both in User variable as well as in System variable.....as i think you changed your path only in system variable...so you should change it on both place..
2. copy your jdk 1.4 path from your container whichever is the path and past in path variable in both places.

then open your command prompt again... and try...
i hope it may solve your problem....

But if i am wrong then please forgive me for my unusual suggestion...
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arvind Gangwar wrote:But if i am wrong then please forgive me for my unusual suggestion...

Your suggestion is not technically wrong, but using Java SE 1.4 or Java EE 1.4 at this point is just asking for trouble. Both have been obsolete for years, and should be phased out as soon as possible. Certainly no new development should use either (or Java SE 5, actually).
 
Arvind Gangwar
Ranch Hand
Posts: 37
MyEclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
you are right dear but i just try to answer what you ask in this thread...as you asked how can i downgrade the JDK path in EV.? How can i match the versions so that i am able to compile.

so keep it up...
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arvind Gangwar wrote:i just try to answer what you ask in this thread...

I understand, but sometimes the best way to answer a question is to challenge the underlying assumptions. (And please note that it wasn't me who asked the question - Mayank Kalbhor did.)
 
Mayank Kalbhor
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually installed JEE 6 (Glassfish). The problem was solved.

Mayank
 
parampreet sethi
Greenhorn
Posts: 27
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have faced a similar problem when my eclipse was using jdk 6 and compiling the code in jdk 6. How ever my tomcat was using java 1.5. And at runtime I was getting "Bad version number in .class file" error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic