I am using apache (2.2.15)
and tomcat6 (6.0.24)
on CentOS 6.4
and would like to use the feature with tomcat server that generates the mod_jk.conf file automatically by adding:
<Listener className="org.apache.jk.config.ApacheConfig" workersConfig="/usr/share/tomcat6/conf/jk/workers.properties" modJk="/usr/lib/httpd/modules/mod_jk.so" />
in tomcat's server.xml file just before </Engine>
tag. It work just fine and generates the mod_jk.conf file for me. Here is a copy of the generated mod_jk.conf:
########## Auto generated on Thu Dec 05 08:32:05 PST 2013##########
<IfModule !mod_jk.c>
LoadModule jk_module "/usr/lib/httpd/modules/mod_jk.so"
</IfModule>
JkWorkersFile "/usr/share/tomcat6/conf/jk/workers.properties"
JkLogFile "/usr/share/tomcat6/logs/mod_jk.log"
JkLogLevel emerg
<VirtualHost localhost>
ServerName localhost
JkMount /CallOffice ajp13
JkMount /CallOffice/* ajp13
JkMount /Diag289 ajp13
JkMount /Diag289/* ajp13
</VirtualHost>
The problem is that I need the apps under tomcat to be accessible by IP or DNS name and can't get at my apps under tomcat through apache (http://serverIP/CallOffice/CallOffice.jsp)
. According to the documentation here:
http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
mod_jk.conf can have a VirtualHost tag like:
# All URL goes to tomcat except the one containing /home
<VirtualHost *:80>
For background info, the following in server.xml generates the <VirtualHost localhost>
tag in mod_jk.conf when it is auto-generated:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
Under this configuration, you can't access tomcat apps through apache unless you're on the server using localhost. To get a configuration that works, I have to add:
<Host name="*:80" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
to tomcat's server.xml file. This makes the mod_jk.conf file look like this:
########## Auto generated on Thu Dec 05 08:38:52 PST 2013##########
<IfModule !mod_jk.c>
LoadModule jk_module "/usr/lib/httpd/modules/mod_jk.so"
</IfModule>
JkWorkersFile "/usr/share/tomcat6/conf/jk/workers.properties"
JkLogFile "/usr/share/tomcat6/logs/mod_jk.log"
JkLogLevel emerg
<VirtualHost *:80>
ServerName *
JkMount /CallOffice ajp13
JkMount /CallOffice/* ajp13
JkMount /Diag289 ajp13
JkMount /Diag289/* ajp13
</VirtualHost>
<VirtualHost localhost>
ServerName localhost
JkMount /CallOffice ajp13
JkMount /CallOffice/* ajp13
JkMount /Diag289 ajp13
JkMount /Diag289/* ajp13
</VirtualHost>
This configuration works and I can get to my apps (http://serverIP/CallOffice/CallOffice.jsp)
but when I start up tomcat I get the following error:
Dec 5, 2013 8:38:52 AM org.apache.catalina.core.StandardContext preRegisterJMX
INFO: Error registering ctx with jmx
StandardEngine[Catalina].StandardHost[*:80].StandardContext[/CallOffice] null
javax.management.MalformedObjectNameException: Invalid character ':' in value part of property
javax.management.MalformedObjectNameException: Invalid character ':' in value part of property
Dec 5, 2013 8:38:52 AM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
javax.management.MalformedObjectNameException: Invalid character ':' in value part of property at javax.management.ObjectName.construct(ObjectName.java:617)
Dec 5, 2013 8:38:52 AM org.apache.catalina.core.StandardContext start
SEVERE: Error in resourceStart()
Dec 5, 2013 8:38:52 AM org.apache.catalina.core.StandardContext registerJMX
INFO: Error registering wrapper with jmx
StandardEngine[Catalina].StandardHost[*:80].StandardContext[/CallOffice] null
javax.management.RuntimeOperationsException: Object name cannot be null
javax.management.RuntimeOperationsException: Object name cannot be null`
Tomcat hates seeing any host tag in server.xml
that has an '*' in it. But this is needed for my deployment where users sometimes use IP address to access the apps. I know I can just use a static version of mod_jk.conf to get what I need, but I would like to use an auto-generating mod_jk.conf file because new .war files added to tomcat will be configured automatically in mod_jk.conf without having to update a static mod_jk.conf file.
Any ideas here?? Even though I get the errors in Tomcat's log file when starting, my apps still work..Ignore tomcat's errors?? or go with a static mod_jk.conf file with no virtual tag or <VirtualHost *:80>
to get what I want??
Well here's your answer - go with a static mod_jk.conf file.
Tomcat user list archive
The tomcat developers considered this ApacheConfig auto-generation functionality not to be good enough for production, and in tomcat 7, it was removed. Presumably the issue was too complex and not high enough priority.