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.
Solaris 7 (Intel) running on an Abit dual processor motherboard. JDK 1.1.7
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.
Include path_to_configuration_file/tomcat.conf
Example:
Include /usr/local/apache/conf/tomcat.conf
Change the following from the default example provided
# this used to be on
ApJServManual off
#Add the following from the default example provided
ApJServProperties /usr/local/apache/conf/tomcat.properties
# comment out the following
#ApJServMount /examples /root
# Add the following
ApJservMount /examples /root
<Location /examples/WEB-INF/>
AllowOverride None
Order allow,deny
Allow from all
</Location>
# The Java Virtual Machine interpreter.
wrapper.bin=/usr/bin/java
# classpaths for the interpreter to use. Some of these are
# not needed since they do not exist anyway
wrapper.classpath=/path_to_tomcat3.1/classes
wrapper.classpath=/path_to_tomcat3.1/webserver.jar
wrapper.classpath=/path_to_tomcat3.1/lib/servlet.jar
wrapper.classpath=/path_to_tomcat3.1/lib/jasper.jar
wrapper.classpath=/path_to_tomcat3.1/lib/xml.jar
wrapper.classpath=/usr/java1.1/lib/classes.zip
# this is the class that starts Tomcat. This used to be
# defaulted in the JServ code as org.apache.jserv.JServ
wrapper.class=org.apache.tomcat.startup.Tomcat
# You will need the modified mod_jserv files to make this
# work.
wrapper.class.parameters=-config path_to_config/server.xml
# I think this is still needed
bindaddress=localhost
# I think is this also still needed
port=8007
# This does not seem to work but even if I add the ip
# address of an outside host, it still would not let it
# connect directly. Need to investigate this somemore
security.allowedAddresses=127.0.0.1
security.allowedAddresses=ip_of_my_host
Please note that the file versions are 1.1 from CVS. You might have something newer and these files might not work with your current src
I can now place something like: #wrapper.class.parameters=-config path_to_config/server.xml
in my jserv.properties file to look for the proper server.xml
Here are the files that I made mods to:
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.
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.
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.
Tomcat+Apache-HOWTO - found in the jakarta-tomcat directory
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
Copyright © 1999 Freddie Mendoza