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
# Set properties for worker1 (ajp13)

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'. 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:

  1. you type a trailing slash http://host/tomcat7/, not http://host/tomcat7.
  2. you have a AJP 1.3 connector listen on port 8009 in server.xml:

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

If it still doesn't work, I suggest you turning on debug and take a look at mod_jk.log.


If you use:

JkMount  /tomcat7/* worker1

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:

<VirtualHost *:80>
    ServerName  xx
    ServerAdmin xx

    JkMount /tomcat7 worker1
    JkMount /tomcat7/* worker1
  • I tried with and without the slash and the server.xml contains the mentioned line. The mod_jk.log doesn't contain something interesting, only the message, that mod_jk was initialized. – Mnementh Sep 9 '11 at 5:44
  • 1
    Did you set JkLogLevel to debug and reload/restart Apache? Try this: http://host/tomcat7/xx. Post the entire content of server.xml. – quanta Sep 9 '11 at 5:52
  • Ah, thanks for the hint with the log-level. – Mnementh Sep 9 '11 at 19:23
  • Please check out my above edited answer. – quanta Sep 10 '11 at 3:25

I had the same problem. The solution is to change JkMount /tomcat7* worker1 to JkMount /your-servlet-app* worker1. You can have as many JkMount as you want.

For example, after adding JkMount /manager* worker1, you will be able to access http://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 - - [04/Mar/2016:13:14:39 +0800] "GET /tomcat-demo/manager/ HTTP/1.1" 404 1009 - - [04/Mar/2016:13:26:05 +0800] "GET /tomcat-demo/manager/http/ HTTP/1.1" 404 1019 - - [04/Mar/2016:13:40:33 +0800] "GET /manager/ HTTP/1.1" 302 - - - [04/Mar/2016:13:40:33 +0800] "GET /manager/html?org.apache.catalina.filters.CSRF_NONCE=E68B5F7E6E96D09C75A8D6854ECE9092 HTTP/1.1" 401 2474 - yz [04/Mar/2016:13:40:35 +0800] "GET /manager/html?org.apache.catalina.filters.CSRF_NONCE=E68B5F7E6E96D09C75A8D6854ECE9092 HTTP/1.1" 200 12405

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.