aspose file tools*
The moose likes Tomcat and the fly likes Tomcat/httpd connection with mod_jk ... Apache connecting to wrong Tomcat instance? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat/httpd connection with mod_jk ... Apache connecting to wrong Tomcat instance?" Watch "Tomcat/httpd connection with mod_jk ... Apache connecting to wrong Tomcat instance?" New topic
Author

Tomcat/httpd connection with mod_jk ... Apache connecting to wrong Tomcat instance?

Eli Wood
Ranch Hand

Joined: Sep 04, 2008
Posts: 37

I have Apache http 2.2.4 and 5 different instances of Tomcat running on a server (Windows Server 2003), all as windows services.

I have attempted to use mod_jk so when the user goes to http://servername he/she is sent to the same Tomcat instance as http://servername:8080

Here is the relevant line in httpd's workers.properties file:
workers.tomcat_home="D:\Program Files\Apache Software Foundation\Tomcat 6.0"
^ This is the Tomcat instance at port 8080

But when the server must be restarted for any reason, httpd starts to point to another (incorrect) instance of Tomcat. I basically have to shut down all my tomcat instances and httpd and restart them in a particular order to get httpd pointing to port 8080.

Are my settings in workers.properties being ignored? If so, why? Is it possible some mod_jk settings are hidden in the registry? How can I set the configuration to point to my desired tomcat instance without having to manually restart everything?

Thanks for your help and consideration, it is much appreciated. If I can provide any more relevant information please let me know.
Eli Wood
Ranch Hand

Joined: Sep 04, 2008
Posts: 37

I just had to restart Tomcat again, and Apache is still connecting to different Tomcat instances. It MAY be choosing the running instance which was most recently started.

It connected to the tomcat instance at port 8086, then I had to restart apache and another tomcat instance to get it back on port 8080. I didn't change the apache configuration at all.

I would expect it to attempt to connect to the same instance each time, and display a service unavailable page if that instance was unavailable.

No clues what might be causing this behavior?
Eli Wood
Ranch Hand

Joined: Sep 04, 2008
Posts: 37

I don't know if anyone is interested, but I reproduced this error on another machine.

I configured httpd to look for a particular Tomcat instance by setting tomcat_home in workers.properties
Then installed two instances of tomcat by downloading the zip file and running "service.bat install Tomcat" and "service.bat install Tomcat2"
Now mod_jk will connect to either Tomcat depending on startup order instead of following the configuration in workers.properties

I'm now assuming this is a bug and will look into filing a bug report and may try to hack my own solution. It's been a while since I've worked in c though.
Eli Wood
Ranch Hand

Joined: Sep 04, 2008
Posts: 37

It's a good thing I was too uncertain to report this as a bug I guess.

mod_jk will by default forward ajp13 requests to a tomcat it assumes is listening on port 8009. It also seems tomcat comes with a server.xml file that preconfigures it to listen on port 8009 for ajp13 requests.

So I think port 8009 would get occupied by the first Tomcat to start up and the other instances would fail to start that connector, but continue starting up their http connectors on port 8080, 8086, etc. So I set the ajp connector in the desired tomcat's server.xml to an unusual port, set the ajp port in workers.properties to the same unusual port, and it looks like it's working!

PS It doesn't seem mod_jk really uses that tomcat_home setting the way I thought it did.

Anyway, thanks for the help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat/httpd connection with mod_jk ... Apache connecting to wrong Tomcat instance?