Tomcat – How to configure uriworkermap.properties in server.xml for Apache – Tomcat integration

503-errorajpapache-2.2connectortomcat

I am so close to completing my first custom install that I can 'taste it' … I am following Apache Tomcat install and I have both servers working side-by-side. My Apache server is configured to the public IP and delivers HTML and XML pages to the internet.

My Tomcat, works with localhost:8080 and I can execute sample JSP, Servlets, Applets, etc.

Now I am interconnecting so Tomcat can service JSP and back-end DB to Apache requests. I found the Tomcat connector and I can verify from the logs that the URL is coming in from the internet, as it gets logged in the Apache log, then gets sent over to Tomcat as I can see the URL in its logs and parsed out components. So far, so good … what isn't happening is the return trip — the response.

The browser now gets a 503 Service Not Available response (huge progress/success) and I can see the ascii/hex response dumped in the logs.

I think the missing piece is getting the rules configured into the server configuration. That is where the install doc got very vague. I have surfed for the answer, but it is all coming back as IIS answers which does not apply to my Apache.

I think the rules are correct, but I need to know how to, "put them in the server configuration." I assume the file goes on the conf/ folder where my workers.properties is stored and I am guessing that the reference goes in 'server.xml' — are those two points correct?? And what section of server.xml does it go in and how is the config-node formatted?

If my question needs more detail, please fire-back and I will provide more.

  • Apache 2.2
  • Windows XP 5.1.26 (ancient but all the SPs are installed)
  • Tomcat 5.2.7
  • Java / JRE / JSDK, etc are all ~1.4.x, 1.5.x and 1.6.x (I would have to dig more for this if needed).
  • Connector is 1.7 (I think) is configured for AJP1.3
  • All standard ports
  • Firewall is Netgear with port forwarding
  • User-id / Passwords are not default
  • Other stuff ????

Also, if there are any more hints on debugging/tracing out this issue – I would like to get that documented for my client.

Best Answer

Badly Badly misread the title of the question - Long day. The command directive you are looking for is this:

JkMountFile

You would put this directive in your httpd.conf (or a seperate mod_jk.conf depending on how you are setup)

From the documentation for apache

File containing multiple mappings from a context to a Tomcat worker. It is usually called uriworkermap.properties. For inheritance rules, see: JkMountCopy. There is no default value.


I'll leave this here in case anyone is interested.

So, since you have a workers.properties you are probably using mod_jk (which has been depreciated for mod_proxy_ajp*). workers.properties are actually part of the mod_jk configuration.

Yes, the documentation for mod_jk is pretty light. So I'll just go ahead and show you my production configuration as an example - you might have to modify it slightly as we run *nix boxes but the concepts are the same.

  1. You httpd.conf should have something similar to this: This tells apache to include a seperate mod_jk configuration file (you can actually put those directives right in the httpd.conf but... i like modularity). Then configure the alias, and the mount point for your jsp files.

    Include <path_to_mod_jk.conf>
    <VirtualHost *:80>
    JkAutoAlias /usr/tomcat/webapps
    JkMount /<your_webapp>/*.jsp <your_worker>
    
  2. Your mod_jk.conf should look something like this:

This is where you set all of your generic mod_jk setting for apache, logs, workers file, etc.

    #MOD_JK Config File
    JkWorkersFile <path_to_your_workers.properties>
    JkLogFile /var/log/httpd/mod_jk.log
    JkLogLevel error
    JkShmFile /var/run/mod_jk.shm

3. And finally you should have a workers.properties similar to: Finally we get to the meat of the config. This is where you setup the worker. the options are pretty self explanatory.

    worker.<your_worker_name>.type=ajp13
    worker.list=<your_worker_name>
    #Worker Config
    worker.<your_worker_name>.host=127.0.0.1
    worker.<your_worker_name>.port=8009
  • And yes, i still run this in production although we are starting a modernization project that will probably see the end of mod_jk and a migration to mod_proxy_ajp