| Author |
Problem with the first example of HFSJ
|
Anitha Ramaswamy
Greenhorn
Joined: Jan 09, 2006
Posts: 9
|
|
Hi all, This problem might seem silly. I'm able to compile the java file and deploy the web app. But when I try to run it, using "http://localhost:8080/ch1/Serv1", I'm geting this error: root cause java.lang.UnsupportedClassVersionError: (Ch1Servlet) bad major version at offset=6 at java.lang.ClassLoader.defineClassImpl(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:211) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:147) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:811) Please can anyone tell me what to do with this! Should I use any other JDK version for compiling this?? Regards, Anitha
|
SCJP, SCWCD, SCDJWS, SCEA-I
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
Which version of java did you use to compile it ? And under which version of JRE is your web app running ? Make sure that they are same.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Anitha Ramaswamy
Greenhorn
Joined: Jan 09, 2006
Posts: 9
|
|
I'm using Sun JDK 1.5.0_05 for compiling teh java file and the JRE version is also 1.5.0_05. They are the same.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
Are you sure there is no other version of Java on your system ? Please check JAVA_HOME. And on the command line, check java -version (please be careful of the Naming Policy )  [ January 16, 2006: Message edited by: Satou kurinosuke ]
|
 |
Anitha Ramaswamy
Greenhorn
Joined: Jan 09, 2006
Posts: 9
|
|
C:\SCWCD\HFSJ\project1\classes>java -fullversion java full version "1.5.0_05-b05" and JAVA_HOME = C:\Program Files\Java\jdk1.5.0_05\jre Regards, Anitha
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
"Anitha", we don't have many rules around here but our naming policy is one of them. Not complying with the policy will lead to your account becoming locked. This warning hopefully will prevent that from happening, but some action is required on your part. Please review the policy here and you can change your Publicly Displayed Name here. (Hint: Your name should have two words.)
|
A good workman is known by his tools.
|
 |
Anitha Ramaswamy
Greenhorn
Joined: Jan 09, 2006
Posts: 9
|
|
Sorry for the blunder created with display name.... My real name isi Anitha, and finally I have maintained it as the display name.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
Can you also try "java -version" ? Thanks. Also, which server are you using ?
|
 |
Anitha Ramaswamy
Greenhorn
Joined: Jan 09, 2006
Posts: 9
|
|
C:\SCWCD\HFSJ\project1\classes>java -version java version "1.5.0_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05) Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing) I'm using Tomcat Server 5.0.28. And I have been using servlets in the past. But I don't know why I'm getting this exception !!
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
Did you compile on the command line, or are you using a GUI ?
|
 |
Anitha Ramaswamy
Greenhorn
Joined: Jan 09, 2006
Posts: 9
|
|
I compiled it on command line using the command : javac -classpath C:\jakarta-tomcat-5.0.28\common\lib\serv let-api.jar -d classes src\Ch1Servlet.java
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
Also check Tomcat's properties, to make sure it uses JRE 1.5 (In Tomcat 5.5, there is a link "Configure Tomcat". How about 5.0 ? )
|
 |
Anitha Ramaswamy
Greenhorn
Joined: Jan 09, 2006
Posts: 9
|
|
I got it working I saw the config in Tomcat server. It was using a different version of Java. Thanks a lot for your time and response Regards, Anitha
|
 |
Vishnu Prakash
Ranch Hand
Joined: Nov 15, 2004
Posts: 1026
|
|
JAVA_HOME = C:\Program Files\Java\jdk1.5.0_05\jre
This is NOT correct. Modify it to.
JAVA_HOME=C:\Program Files\Java\jdk1.5.0_05 TOMCAT_HOME=C:\jakarta-tomcat-5.0.28 classpath=%classpath%;.;C:\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar;
What version of windows are you using?
|
Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
Got it working ? Great. Don't forget to look at Marc and Vishnu's comments too
|
 |
Anitha Ramaswamy
Greenhorn
Joined: Jan 09, 2006
Posts: 9
|
|
Sure. I find this forum really interactive and helpful. Thanks all, Anitha
|
 |
 |
|
|
subject: Problem with the first example of HFSJ
|
|
|