<< This One Is For Brian, Brian, Brad and David And Anyone Who Bought AppleTV Last Week | Home | Innovation Through Polls Considered Meaningless >>

Tomcat 5 on Fedora Core 6: In Five Easy Steps

Have you noticed anything different about this blog in the past 24 hours?

I moved it to my newly upgraded Fedora Core 6 workstation yesterday. And I'm happy to report that setting Tomcat up on a Fedora Core 6 is extremely easy. I'll outline the steps I took to set up a functional Tomcat 5 server:

Install FC6 and Apache Web Server

Stick the Fedora Core 6 DVD in and reboot. Then follow the instructions. I took all defaults where I can, including letting it "delete all Linux partitions" and automatically partition the disk. I choose to install "Web Server" and "Development Tools" when offered the chance. This installs the Apache Web Server 2.2.3 on the box.

Install Tomcat

Tomcat 5 is included in Fedora Core 6, but not installed by default. So I have to bring it in from the repository:

[root@gao]# yum install tomcat5 tomcat5-webapps tomcat5-admin-webapps

This installs Tomcat 5.5.17 and a lot of their dependencies onto the system.

Hook up Tomcat 5 with Apache Web Server

Since I don't want my users to have to type ":8080" all the time, I went ahead and hooked up Tomcat 5 to httpd. In the past, this step had been the most confusing. I remember spending days browsing through Tomcat's website trying to figure out which one of the three alternatives offered there is the one that worked. I still have the mod_jk.so that I compiled from CVS source somewhere on by backup CD-ROMS.

In Fedora Core 6, things are quite straightforward because the version of httpd included contains mod_proxy_ajp which allows httpd to talk to Tomcat 5 through the AJP protocol, which Tomcat 5 listens to on port 8009. To make the connection, I edited /etc/httpd/conf.d/proxy_ajp.conf so that it reads (excluding comments):

[root@gao]# cat /etc/httpd/conf.d/proxy_ajp.conf
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
ProxyPass /blog ajp://localhost:8009/blog

Turn on the services

To have httpd and Tomcat 5 start automatically upon reboot, I went to the System->Administration->Services menuitem and enabled both the httpd and tomcat5 services.

Now I have a working Tomcat 5 server. It's webapps directory is at /usr/share/tomcat5/webapps.

Install Sun JDK

So far we have been using the default Java package that came with Fedora Core 6, which is a Free Software implementation of Java based on GNU Gcj, GNU Classpath, and the Eclipse compiler. To run the widest set of Java applications and servlets, I need to install the Sun JDK.

The best way of installing Sun JDK on Fedora Core 6 is to follow the JPackage.org method. I wrote an Introduction to JPackage.org 782 days ago. Things haven't changed much since then (except that now Fedora Core includes a bunch of Java packages, which makes my life easier).

To follow the JPackage.org method, I need to make sure that the following packages are installed:

[root@gao]# yum install jpackage-utils rpm-build libXp unixODBC unixODBC-devel

The first two were already installed when I checked. The others are needed by the JDK.

Then I need to download the JDK (Linux self-extracting file) from Sun's website.

Now we are five command lines away from success:

[root@gao]# rpm -ihv http://mirrors.dotsrc.org/jpackage/5.0/generic/\
non-free/SRPMS/java-1.5.0-sun-1.5.0.10-2jpp.nosrc.rpm
[root@gao]# cp jdk-1_5_0_10-linux-i586.bin /usr/src/redhat/SOURCES
[root@gao]# rpmbuild -ba /usr/src/redhat/SPECS/java-1.5.0-sun.spec
[root@gao]# cd /usr/src/redhat/RPMS/i586
[root@gao]# for x in java-1.5.0-sun-*.rpm; do rpm -ihv $x; done

[Update (Thu Apr 26 06:10:52 CDT 2007)] As Sun makes update releases of the JDK, JPackage.org updates their nosrc.rpm version number that is available from their archive. Since Sun does not cordinate its JDK release with JPackage.org, their will be some lag time before a new nosrc.rpm appears in the JPackage.org archive after each Sun release. As of yesterday, the first two of the above five commands should be updated to

[root@gao]# rpm -ihv http://mirrors.dotsrc.org/jpackage/5.0/generic/\
non-free/SRPMS/java-1.5.0-sun-1.5.0.11-1jpp.nosrc.rpm
[root@gao]# cp jdk-1_5_0_11-linux-i586.bin /usr/src/redhat/SOURCES
Tags :


Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

O.K. I ran rpm -ivh

http://mirrors.dotsrc.org/jpackage/5.0/generic/non-free/SRPMS/java-1.5.0-sun-1.5.0.11-1jpp.nosrc.rpm 

But, I don't see what to copy

/usr/src/redhat/SPECS/java-1.5.0-sun.spec does exist

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

well i tried to exactly  what u said but still im getting these errors on fc6  . My catlina.out shows the following error

any solution


Mar 21, 2007 4:11:59 AM org.apache.jk.common.MsgAjp processHeader
SEVERE: BAD packet signature 18245
Mar 21, 2007 4:11:59 AM org.apache.jk.common.ChannelSocket processConnection
SEVERE: Error, processing connection
java.lang.IndexOutOfBoundsException at java.io.BufferedInputStream.read(BufferedInputStream.java:306)

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

O.K. Got thru all five steps after obtaining JDK from Sun. (Of course, I downloaded the wrong one first, rpm.bin, rather than bin.)

Commented our the JAVA_HOME and JRE_HOME statements previously added to /etc/profile

Rebooted.

 - Able to see Tomcat
 - Get a 404 for Pebble

/usr/sbin/alternatives --display java is different than previous. It would seem that a number of slave statements have been added for 1.5.0. Also now the current best version has changed to /usr/lib/jvm/jre-1.5.0-sun/bin/java.
Have yet to try /usr/sbin/alternatives --config java

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

O.K. ran 'sudo /usr/sbin/alternatives --config java
Switched choice to 1.5
Stopped and re-started Tomcat

Got Tomcat, get 404 for pebble

Yes, I would like some cheese and eight stones with my whine.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Check the Apache httpd log files (access.log and error.log in /var/log.httpd) and the Tomcat 5 log files (catalina.log in /var/log/tomcat5) to see if you can get any clue as to what the problem is.

I used "blog" rather than "pebble" when hooking up Apache httpd and Tomcat 5 because when I deployed the Pebble war file I also renamed it:

cp pebble.war /use/share/tomcat5/webapps/blog.war

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

back to old problem of FAIL - Application at context path /blog could not be started /var/log/tomcat5.catalina.out has lots of error messages, which resemble previous problems before I build a version with ant, rather than deploying war BTW: When you suggested checking Apache logs, I realized that I had not added the configuration, but doing that and restarting Apache and Tomcat made no difference. Should the port be 8009 or 8080?

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

So d/l /trunk from svn again. Ran ant. Build successful. True status in Tomcat manager 404 error when I load localhost:8080/pebble or localhost:8080/pebble/web

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

It may not be much and you may have given up on this, but in any case, if I cp pebble/web/WEB-INF to pebble/WEB-INF, then Tomcat says pebble NOT running. The error message is the same that plagues me when I deploy, i.e., FAIL - Application at context path /pebble could not be started. If I then remove WEB-INF and refresh Tomcat manger display, it says that pebble is running. I never am able to access it.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Wait a minute.  It sounds like your Pebble deployment is different from mine.  Mine is done this way:

[weiqi@gao]$ unzip pebble-2.0.1.zip
[weiqi@gao]$ cd pebble-2.0.1
[weiqi@gao]$ cp pebble.war /usr/share/tomcat5/webapps

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Yes, I understand, you want me to listen to you without you listening to me. Understood. To repeat, when I do what you do, itta donna work, hokay? Context path error. The only way that I have been able to get the tomcat manager to show that pebble is running is run ant on a build.xml from /trunk. It still doesn't work, but it does show that it works.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

If you think you are frustrated that the thing simply doesn't work, I'm more frustrated that Pebble doesn't work for you and I know very little about what you did and how it doesn't work.

I have prepared a little screencast of my Pebble setup, and you can find it here. Maybe you can spot something that's different between your deployment and mine and figure out what is wrong with your setup.

If you feel it will be of any help to you, you can create a similar screencast (you can do it with istanbul from the Audio and Video Application group in the menu) of your setup and put it on your web server somewhere. I'd be glad to take a look.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

K.O., will take a look-see.

Lights, cameras, blender...

Meanwhile, I was able to install everything quite easily on a WinXP machine, so that I could see what it was like to use Pebble.

It was very easy to install. It was a bit tricky to establish myself as a user with a unique password, rather than entering as username and password.

It has a nice interface and I like the idea of using XML.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

You must be an Ace developer. You were able to prove your point to me while frustrating me even more. Yes, the several times that I watched the recording, what I saw looked familiar (although I would have like to have read the contents of WEB-INF/web.xml and WEB-INF/applicationContext-pebble.xml). So, although I never saw proof of a working system, I believe that what I saw represented one. It looked liked the results of a deployed pebble.war So, I tried to respond in kind. 1. Istanbul was not in my menu, so I had to install it with yum. 2. Then I spent several frustrating hours trying to figure how to save something that you could see. Oh, yes, it works upon install, in that there is a right click menu, clicking it starts and clicking it again stops, but then... Nothing except the icon stays in the notification area and the only way to make it go away is to reboot. What I tried to record several times was a view of Tomcat manager. Then I stopped Pebble - OK. Then I started it again - OK. Then I tried several different ways to load it into the browser -- always with a 404 resource unavailable message from Tomcat. So, then I opened a window, went to where there is a copy of pebble.war, copied it to webapps as instructed, then return to Tomcat manager. The recording would then have shown you that deployment had occurred, but that it was not running. I click start and after a while the FAIL - Context path error appears. The last frames would show me successfully undeploying it. But, since I was unable to succeed at how to save the *.ogg, there is no visual record that I could likewise provide.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Mm, this is interesting. Problems with deployment of Pebble. Also similar problems with JSPWiki, so I suspected my Java config. Yet Very Quick Wiki deployed, no problem. Tomcat manager showed it was running true from the outset and clicking on the link took me to a start page. No where as nice an app as the aforementioned, but it does work for me.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Hello Weiqi: What a great article to follow for novicies like me. I have a question though: The last five steps are not working. But then I got the first one working by changing ...SRPMS/java-1.5.0-sun-1.5.0.10-2jpp.nosrc.rpm to ....SRPMS/java-1.5.0-sun-1.5.0.11-1jpp.nosrc.rpm as the version number has changed. Now when I run the second command it comes back and tell me: cp: cannot stat 'jdk-1_5_0_10-linux-i586.bin': no such file or directory. Can you please help? Thank you. --R.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Since you have gotten the more up=to-date nosrc.rpm file, you should download the corresponding jdk-1_5_0_11-linux-i586.bin file from Sun's JDK download page, and copy that file to /usr/src/redhat/SOURCES.

The second command is meant to be run from the directory where the jdk-1_5_0_11-linux-i586.bin file is saved on your hard disk.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Hey Weiqi: I looked on the sun.com site and could not figure out where to download the "jdk-1_5_0_11-linux-i586.bin" file from. Any ideas? Thanx again, --R.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Weiqi: Scratch the last request. It's late and I was tired and did not look at the right spot. Do you think it's a good idea to update your excellent tutorial with the updated info? Users will get an error if they use the first command out of the last five. Thank you so much again. --R.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Done.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Hi Gao, actually I have a issue with tomcat and apache (ajp): As you wrote, I connect tomcat5.5 with apache(come with fc6) using ajp. It works very well, until... for some jsp/servlet pages, it display the html source code instead of displaying the pages, and it only happend in Firefox, not in IE. I disable the ajp, and connect to tomcat directly, it works fine both firefox and IE. So I am just wondering are there any bugs in ajp(apache to tomcat)? cause I don't think firefox is the problem. looking forward ur reply. thanks

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

I upgraded to Tomcat 5.5.23 and now have problems. All jsp-examples work except the JSP 2.0 Examples called JSP Configuration. Furthermore, all my previously working JSP pages fail as they call taglibs. What is wrong? I went to another machine and loaded Fedora 7 and have the same problem.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

How do I install JDK 6 using JPackage? Thank You.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

I follow the steps above, I get the following error message when develop servlet with eclipse: Project myApp is missing required library: '/usr/share/tomcat5/common/lib/jasper-runtime.jar' Project myApp is missing required library: '/usr/share/tomcat5/common/lib/jsp-api.jar' Project myApp is missing required library: '/usr/share/tomcat5/common/lib/servlet-api.jar' Please help?

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

As I do not use Eclipse on FC6, I cannot diagnose your problem.

From the error message it seems that you need to let your myApp project know where the requested jar files are.

On FC6, the jar files are all installed in /usr/share/java/ or its subdirectories.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Would anyone be kind enough to direct me to a site where I can get information on downloading Tomcat 5 for Fedora Core 5. I've been struggling on this for days. I downloaded an Apache Tomcat 5.5.23 - I'm having an enormous amount of problems finding a compatible JDK! I get a variety of errors everytime i try ./startup.sh. And I'm pretty sure it's because of this issue that comes up with JDK and Fedora Core 5! Any help would highly be appreciated! Thanks.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

I've found that the Tomcat5 service keeps using Fedora's faulty JVM instead of the new installed one from SUN. The solution was to edit the /etc/sysconfig/tomcat5 file so that the JAVA_HOME variable points to the directory of the SUN version of the JVM.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

I did not have to do that. Did you install the Sun JDK the way I outlined (by creating an RPM using the JPackage.org *.nosrc.rpm specification)? If so, when the resulting RPM is installed, the system will automatically update itself into using the Sun JDK for all Java tasks.

You can switch between the two JDK versions (Sun JDK and GCJ) using the alternatives mechanism.

Editing Tomcat's configuration file will only change the JDK that is used by Tomcat. Chances are that your Ant and Eclipse and many other Java applications are still using the GCJ JDK. Tracking down the configuration files for each of them and figuring out how to modify them so that they may pick up the Sun JDK is a rabbit hole that you probably don't want to get into.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

I tried to do it with the rpm -ihv command as you described (updated to the packages that are now there) but this is what I got:

[root@localhost ~]# rpm -ihv http://mirrors.dotsrc.org/jpackage/5.0/generic/non-free/SRPMS/java-1.6.0-sun-1.6.0.2-1jpp.nosrc.rpm
Retrieving http://mirrors.dotsrc.org/jpackage/5.0/generic/non-free/SRPMS/java-1.6.0-sun-1.6.0.2-1jpp.nosrc.rpm
warning: /var/tmp/rpm-xfer.1EhpXf: Header V3 DSA signature: NOKEY, key ID c431416d
1:java-1.6.0-sun warning: user jacorley does not exist - using root
warning: group jacorley does not exist - using root
warning: user jacorley does not exist - using root
warning: group jacorley does not exist - using root
warning: user jacorley does not exist - using root
warning: group jacorley does not exist - using root
########################################### [100%]
[root@localhost ~]#

Should I have created this jacorley user on my machine?

Anyway, I installed the software directly from SUN and I made the change I described before, and now all my servlets work well.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

By the way, I had selected the new JVM as the default JVM before I finally changed tomcat5's configuration file.

This is what I had done:
[root@localhost ~]# /usr/sbin/alternatives --install /usr/bin/java java \
/opt/SDK/jdk/bin/java 1601

[root@localhost ~]# /usr/sbin/alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
1 /usr/lib/jvm/jre-1.5.0-gcj/bin/java * 2 /usr/java/jre1.6.0_01/bin/java + 3 /opt/SDK/jdk/bin/java Enter to keep the current selection[+], or type selection number: 3 [root@localhost ~]#
That made it the default JVM for everything but Tomcat5's service on Fedora (unless I started it using the ./startup command.)

I had to change Tomcat5's configuration file like this:
[root@localhost ~]# cat /etc/sysconfig/tomcat5
[...]
#JAVA_HOME="/usr/lib/jvm/java"
JAVA_HOME="/opt/SDK/jdk"
[...]
If I changed /etc/tomcat5/tomncat5.conf instead that file would be overiden by the settings in /etc/sysconfig/tomcat5, so I had to change this one instead.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

I guess your situation is different from mine. Thank you for sharing the information. Someone else might benefit from it.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Why not just select Tomcat and Java during the Fedora Core 6 installation? Is there some advantage provided by not including them, then installing them later using yum?

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

You can select Tomcat during installation. But the Java that is offered during installation is not Sun Java, but GNU gcj + GNU Classpath + Ecj, which is not adquate to run some of the Java web applications.

Re: Tomcat 5 on Fedora Core 7: In Five Easy Steps

hey Weigi: I am Harsha. I have installed jdk(jdk-1_5_0_13-linux-i586.bin file) the way you have specified in the blog.Tomcat5.5.23 was already installed before the installation of jdk. Tomcat installation i had done during the installation of fedora7. I have also updated /etc/profile file with JAVA_HOME="/usr/lib/jvm/java" export JAVA_HOME Now the problem is after the installation of jdk my servlet programs are compiling but I am not getting the output on the browser. Could you please tell me what the problem is and what is to be done to correct this. This is a humble request sir.

Re: Tomcat 5 on Fedora Core 7: In Five Easy Steps

Do not set JAVA_HOME in your <tt>/etc/profile</tt>. This will mask JDK installation issues. Use the "alternatives" command as indicated in an earlier comment.

As you can see from reading earlier comments on this blog entry, troubleshooting Tomcat problems from a long distance is extremely hard and usually frustrating for both ends. So I wont pretend that I can solve your problem. My suggestion is to check your Tomcat log files to figure out what is going on with your web app.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Excellent material - thank you. I installed Tomcat as per these instructions, and can Open File...index.jsp, which displays correctly in Firefox. However, http://localhost:8080/ yields only a blank page. Nothing in the logs seems terribly helpful. The default port in tomcat5.conf is 8080, although this doesn't show up in "netstat -plut". Any suggestions most welcome.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

Hi Gao Thx for your sharing experience. I just followed your steps to build my own tomcat. I found everything was ok except the "java-1.6.0-sun-jdbc-1.6.0.3-1jpp.i586.rpm". When I install this package, the system told me that: java-1.6.0-sun-jdbc-1.6.0.3-1jpp.i586.rpm but the fact was that I have already install the unixODBC-devel-2.2.11-6.2.1 & unixODBC-2.2.11-6.2.1. And I could found these two files in the /usr/lib fold. So could your do me a favor about that? thanks a lot.

Re: Tomcat 5 on Fedora Core 6: In Five Easy Steps

You can search the JPackage.org mailing list archives for some conversations on this topic. See for example, this thread.

The java-1.6.0-sun-jdbc-1.6.0.3-1jpp.i586.rpm package contains only the Sun OdbcJdbc bridge. The JDBC core is not in this package, but in the main java-1.6.0-sun package. So unless you are running an app that uses the OdbcJdbc bridge, you can safely ignore the java-1.6.0-sun-jdbc package.


Add a comment Send a TrackBack