Howto Configure Tomcat 3.1 with Apache

Updated for v3.1M2

Introduction

This How-to should mostly work with the latest 3.2 Release except for the modifications for mod_jserv. The mod_jserv files in 3.2 have newer files so if you want to modify them, you can look at my changes and manually modify the new files from 3.2. The mod_jserv files are in the src/native/apache/jserv if it has not been reorganized.

This howto documents my way of configuring Tomcat to automatically startup when Apache is started. Kinda like the way JServ is currently started.

Machine Configuration

Solaris 7 (Intel) running on an Abit dual processor motherboard. JDK 1.1.7

Before You Begin

Before you embark on the having Tomcat automatically startup from Apache please make sure that you can run Tomcat 3.x as a standalone and be able to run the Servlets and JSPs from the examples.

Check Lists

Somethings that I have noticed with this configuration

Test Drive

You now have to restart Apache via "apachectl start". Make sure the standalone Tomcat is shutdown.

Since all logs of Tomcat go to stderr just now, you should see all of the logs you used to see when starting Tomcat as a standalone in the apache error_log.

You can access your site via http://your_server/examples/servlets and http://your_server/examples/jsp.

Debugging tips

If you see somthing in the Apache error_log that says something like invalid scratchDir, you do not have a valid "workDir" in the server.xml file. The server.xml file that you are editing should be in the classes/org/apache/tomcat/shell/deployment directory of Tomcat.

Whether you are running Tomcat as a standalone or started from Apache you should be able to access the Tomcat http server directly via:
http://your_server:8080/
http://your_server:8080/examples/jsp
http://your_server:8080/examples/servlets

If you are starting Tomcat from Apache, you know something is wrong with starting Apache when in the Apache mod_jserv.log you see something like it is starting Tomcat over and over again.

On Unix and I guess also on NT, you should be able to do a "netstat -a" command and see that there is something listening on ports 8007 and 8080. Assuming you are using all the defaults.

Once you finally get a nice directory listing when you access the examples directory you can try to run the servlet examples or jsp examples. If you ever get something like error 500, and the stack trace have something like class not found, suspect that you might not have the right permissions in any of of your class directories for Tomcat. Make sure it is readable by the Apache User set in the Apache httpd.conf.

Disclaimer

This document only serves as an example on how I got Tomcat to run from Apache. This does not serve as an official document from the Jakarta development team.

Visit my other web links

Find cheap books: Price Comparison Engine for the Price Conscious
This engine was written in the WebL scripting language.

AOLServer Plugin for Tomcat

References

Tomcat+Apache-HOWTO - found in the jakarta-tomcat directory

Feedback Please

As always I appreciate any feedback about the howto. I'd like to improve it in anyway to help others who might need configuration help. I guess, let me know if it helped or did not help at all.

I'd also like to add stuff for NT, but I do not have an NT environment I can test it with. So any experience you have had with NT (eg. starting Tomcat within Apache) would be a great addition to this howto.

Just send email to Freddie Mendoza