This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Servlets and the fly likes Loading a servlet using jdk1.4 in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Loading a servlet using jdk1.4 in Tomcat" Watch "Loading a servlet using jdk1.4 in Tomcat" New topic

Loading a servlet using jdk1.4 in Tomcat

Nitin Kumar

Joined: Apr 18, 2005
Posts: 29
Hi ,
I am new to servlets and I am trying to run my first servlet using standalone Toncat Server, but I am getting some errors.

I followed these steps

1 Downloaded and '5.5.9 Compat.jar' from Apache site.
2 Unpacked them in a local directory(D:\Tomcat) . While unpacking '5.5.9 Compat.jar' I replaced some of the jar that were in original folder.
3 I pointed JAVA_HOME to jdk1.4.2_06. This I did using environment variables.
4 Changed the port in D:\Tomcat\jakarta-tomcat-5.5.9\conf\server.xml to 80
5 Modified D:\Tomcat\jakarta-tomcat-5.5.9\conf\web.xml
Uncommented the Servlet-Name and Servlet-Invoker
6 Complided a small java class ( and put the class file into

7 Tried to access the class file using the URL http://localhost/servlet/HelloWorld
But I am getting following error

javax.servlet.ServletException: Cannot allocate servlet instance for path /servlet/HelloServlet

root cause

java.lang.UnsupportedClassVersionError: HelloServlet (Unsupported major.minor version 49.0)
java.lang.ClassLoader.defineClass0(Native Method)

But when I set JAVA_HOME to jdk1.5 , it works fine. Whats wrong here ?
As I have downloaded 5.5.9 Compat.jar and unpacked it, it should work with JDK1.4 also?
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
your servlet (and/or classes it uses) were compiled using a 1.5 compiler. When you try to run them on a 1.4 JVM that's the error you get.

1.4 compilers produce classfiles with an internal version number 48, 1.5 compilers create classfiles with version 49.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13018
The quick solution is to use the compiler option -source 1.4
to produce compatible code.
See the tooldocs for javac for more details
[ April 25, 2005: Message edited by: William Brogden ]
I agree. Here's the link:
subject: Loading a servlet using jdk1.4 in Tomcat
It's not a secret anymore!