aspose file tools*
The moose likes Tomcat and the fly likes Apache Tomcat5.5 clustering problem with Apache HTTP server 2.2.4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Apache Tomcat5.5 clustering problem with Apache HTTP server 2.2.4" Watch "Apache Tomcat5.5 clustering problem with Apache HTTP server 2.2.4" New topic
Author

Apache Tomcat5.5 clustering problem with Apache HTTP server 2.2.4

Tanmoy Biswas
Greenhorn

Joined: Feb 04, 2009
Posts: 4
Hello everybody,

I am new to this forum. I am trying to cluster two Tomcat 5.5.9 with Apache HTTP server 2.2.4 and Connector mod_jk.so for Apache HTTP server 2.2.4 in Windows XP PC of mine.

I have installed all in c:/ drive like c:/tomcat, c:/tomcat2 and c:/Apache2.2.
I placed the mod_jk.so file into the modules folder of Apache HTTP server 2.2.4.

1) I have configured two Tomcat in the way mentioned below:-

1st Tomcat's server.xml:-
a) <Server port="8005" shutdown="SHUTDOWN">
b) <Connector port="8088" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
c) <Connector port="8009" redirectPort="8443" protocol="AJP/1.3" />


2nd Tomcat's server.xml:-
a) <Server port="8025" shutdown="SHUTDOWN">
b) <Connector port="8018" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
c) <Connector port="8019" redirectPort="8443" protocol="AJP/1.3" />


2) I have created workers.properties file in Apache HTTP server's conf folder.

workers.properties:-
workers.tomcat_home=C:/tomcat

workers.java_home=C:/jdk1.5.0_07

worker.list=worker1,worker2

worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.port=ajp13

worker.worker2.port=8019
worker.worker2.host=localhost
worker.worker2.port=ajp13


3) I have written below mentioned lines into Apache HTTP server's httpd.conf file just after LoadModule declaration the in conf folder.

LoadModule jk_module modules/mod_jk.so

#Path to workers.properties
JkWorkersFile C:/Apache2.2/conf/workers.properties

#Path to jk logs
JkLogFile C:/Apache2.2/mod_jk.log

#Jk log level[debug/error/info]
JkLogLevel info

#Jk log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"

#JkOptions for forwarding
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

#JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

JkMount /jsp-examples worker1
JkMount /jsp-examples/* worker1

JkMount /tomcat-docs worker2
JkMount /tomcat-docs/* worker2


Now the problem is when I start the Apache HTTP server 2.2.4 I can see errors in the mod_jk.log file given below.

[Wed Feb 04 11:24:23 2009][4004:2960] [warn] jk_map.c (404): Duplicate key 'worker.worker1.port' detected - previous value '8009' will be overwritten with 'ajp13'.
[Wed Feb 04 11:24:23 2009][4004:2960] [warn] jk_map.c (404): Duplicate key 'worker.worker2.port' detected - previous value '8019' will be overwritten with 'ajp13'.
[Wed Feb 04 11:24:23 2009][4004:2960] [error] jk_ajp_common.c (1997): invalid host and port localhost 0
[Wed Feb 04 11:24:23 2009][4004:2960] [error] jk_worker.c (161): validate failed for worker1
[Wed Feb 04 11:24:23 2009][4004:2960] [error] jk_worker.c (259): failed to create worker worker1
[Wed Feb 04 11:24:23 2009][4004:2960] [warn] jk_map.c (404): Duplicate key 'worker.worker1.port' detected - previous value '8009' will be overwritten with 'ajp13'.
[Wed Feb 04 11:24:23 2009][4004:2960] [warn] jk_map.c (404): Duplicate key 'worker.worker2.port' detected - previous value '8019' will be overwritten with 'ajp13'.
[Wed Feb 04 11:24:23 2009][4004:2960] [error] jk_ajp_common.c (1997): invalid host and port localhost 0
[Wed Feb 04 11:24:23 2009][4004:2960] [error] jk_worker.c (161): validate failed for worker1
[Wed Feb 04 11:24:23 2009][4004:2960] [error] jk_worker.c (259): failed to create worker worker1
[Wed Feb 04 11:24:23 2009][3248:1844] [warn] jk_map.c (404): Duplicate key 'worker.worker1.port' detected - previous value '8009' will be overwritten with 'ajp13'.
[Wed Feb 04 11:24:23 2009][3248:1844] [warn] jk_map.c (404): Duplicate key 'worker.worker2.port' detected - previous value '8019' will be overwritten with 'ajp13'.
[Wed Feb 04 11:24:23 2009][3248:1844] [error] jk_ajp_common.c (1997): invalid host and port localhost 0
[Wed Feb 04 11:24:23 2009][3248:1844] [error] jk_worker.c (161): validate failed for worker1
[Wed Feb 04 11:24:23 2009][3248:1844] [error] jk_worker.c (259): failed to create worker worker1
[Wed Feb 04 11:24:23 2009][3248:1844] [warn] jk_map.c (404): Duplicate key 'worker.worker1.port' detected - previous value '8009' will be overwritten with 'ajp13'.
[Wed Feb 04 11:24:23 2009][3248:1844] [warn] jk_map.c (404): Duplicate key 'worker.worker2.port' detected - previous value '8019' will be overwritten with 'ajp13'.
[Wed Feb 04 11:24:23 2009][3248:1844] [error] jk_ajp_common.c (1997): invalid host and port localhost 0
[Wed Feb 04 11:24:23 2009][3248:1844] [error] jk_worker.c (161): validate failed for worker1
[Wed Feb 04 11:24:23 2009][3248:1844] [error] jk_worker.c (259): failed to create worker worker1


But the server starts successfully. After that I start two Tomcat web servers and they also starts successfully.

Now I open two browser and give a link like:- http://localhost/jsp-examples and http://localhost/tomcat-docs but it shows 500 internal server error in both the browser. I checked the access.log file in logs folder of Apache HTTP server 2.2.4 and I found this:-

127.0.0.1 - - [04/Feb/2009:11:32:50 +0530] "GET / HTTP/1.1" 200 44
127.0.0.1 - - [04/Feb/2009:11:33:47 +0530] "GET /jsp-examples HTTP/1.1" 500 536
127.0.0.1 - - [04/Feb/2009:11:34:02 +0530] "GET /tomcat-docs HTTP/1.1" 500 536


Please correct me if anything is wrong here. Help needed.

Thanks in advance........
Tanmoy

Javid Jamae
Author
Ranch Hand

Joined: May 14, 2008
Posts: 198
In each Tomcat's server.xml you'll have to define the jvmRoute attribute on the Engine element. The value should match the name of the worker defined in Apache.

For example, on Tomcat instance 1:

<Engine ... jvmRoute="worker1">

And on Tomcat instance 2:

<Engine ... jvmRoute="worker2">


Author: JBoss in Action, javidjamae.com, @javidjamae on Twitter
Tanmoy Biswas
Greenhorn

Joined: Feb 04, 2009
Posts: 4
Thanks Javid Jamae,

Thank you for your reply. I think I have done a silly mistake. I have solved that and it is working fine.

The mistake was in workers.properties file. It should be worker.worker1.type=ajp13 and worker.worker2.type=ajp13, not that I have given worker.worker1.port=ajp13 and worker.worker2.port=ajp13. I have changed it and it is working fine.





parthasarathi pandiyan
Greenhorn

Joined: Nov 07, 2008
Posts: 3
Hi,
Today only I have seen your message.In workers.properties file you gave port instead of path in ajp protocol.thatswhat you got this error.please change and check it out.


Regards,
P.Parthasarathi
Jr Software developer,
TouchPoint Solutions,
mail:parthasarathi@touchpointindia.com
 
 
subject: Apache Tomcat5.5 clustering problem with Apache HTTP server 2.2.4