I want to access Tomcat through the Apache-webserver using connectors. I sticked to the documentation: http://tomcat.apache.org/connectors-doc/generic_howto/quick.html I only modified it a little to match directory-structure used on my Debian-(Squeeze)-System.
So I added the following to /etc/apache2/httpd.conf:
# Load mod_jk module
# Update this path to match your modules location
#LoadModule jk_module libexec/mod_jk.so
# Declare the module for <IfModule directive> (remove this line on Apache 2.x)
#AddModule mod_jk.c
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/apache2/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# Send everything for context /examples to worker named worker1 (ajp13)
JkMount /tomcat7/* worker1
I commented out the loading of the module, because that already happens, after I installed mod_jk through the package-system (libapache2-mod-jk).
My workers.properties look like this:
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
Tomcat 7 is installed directly from archive from Apache, because it is not a package in Squeeze. Tomcat 7 is running and reachable under it's own port (8180, to not collide with tomcat6 from the package-system). As far as I understand, I should see now the tomcat-site with http://host/tomcat7/. But I get a 404 instead. What is wrong?
After quanta hinted to set the log-level to debug (thanks) I did that and found the following error-message in mod_jk.log: 'jk_map_to_storage::mod_jk.c (3585): missing uri map for 176.9.9.55:/tomcat7/'. I googled for that and found http://old.nabble.com/mod_jk%2C-missing-uri-map-td23984359.html
So the options set in httpd.conf weren't used in VirtualHosts. I added 'JkMountCopy On' to my VirtualHost - and got first a Tomcat 404 (instead of the httpd 404). Problem here, that he tries to access the exact same URI mounted, so in my case /tomcat7. I used instead the name of the webapp as mount and everything is fine for me.
Make sure that:
you have a AJP 1.3 connector listen on port 8009 in
server.xml
:If it still doesn't work, I suggest you turning on debug and take a look at
mod_jk.log
.EDIT:
If you use:
and access via http://host/tomcat7, I'm sure you will get the Apache 404 error.
You can specify
JkMount
in a Virtual Host section which you want:I had the same problem. The solution is to change
JkMount /tomcat7* worker1
toJkMount /your-servlet-app* worker1
. You can have as manyJkMount
as you want.For example, after adding
JkMount /manager* worker1
, you will be able to accesshttp://host/manager/html
I figured out this problem after I tried both AJP and http. I had the following access log in my
/var/log/tomcat7/localhost_access_log.txt
The first two log lines were generated while I use AJP. The last three were generated while I use http to directly access tomcat. So apache is passing the whole URL to tomcat, instead of removing the jkmount prefix.
Use mod_proxy_ajp or mod_proxy_http instead if you can: http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html http://httpd.apache.org/docs/2.2/mod/mod_proxy_http.html