Apache 2.0.52 + Tomcat 5.0.28 + mod_jk

B

Brent

Hi,

I'm trying to connect Apache 2.0.52 with Tomcat 5.0.28 using the mod_jk
connector, to no avail.

The documentation at
http://jakarta.apache.org/tomcat/connectors-doc/index.html only really
covers Tomcat 4.*.

Has anyone been able to do this on a Windows or Linux platform? Are
there any good resources out there that anyone knows of that I can look
to?

It seems like everything I find refers to mod_jk2, which I just found
out is being discontinued and everything is moving to mod_jk, so I'd
like to use something that will be around for a while.
All help/information is greatly appreciated.

Thanks,
Brent
 
J

Juha Laiho

Brent said:
I'm trying to connect Apache 2.0.52 with Tomcat 5.0.28 using the mod_jk
connector, to no avail.

The documentation at
http://jakarta.apache.org/tomcat/connectors-doc/index.html only really
covers Tomcat 4.*.

There shouldn't be any major changes after that regarding mod_jk set-up.
Has anyone been able to do this on a Windows or Linux platform? Are
there any good resources out there that anyone knows of that I can look
to?

From top of my mind, it's three/four files you're looking for:
- httpd.conf
- module loading/initialization directives for mod_jk
- either including mod_jk.conf to httpd.conf by a directive or
having more or less copy of mod_jk.conf copied into httpd.conf
- mod_jk.conf
- JkMount directives for declaring HTTP resources that should be
served by Tomcat; here the subtrees are assigned to named
"worker"s
- it's possible to get Tomcat to automatically generate pretty much
correct mod_jk.conf -files on startup
- server.xml
- you need to set some listener for AJP13 protocol, at some given
port (not the same as your actual WWW service port); additionally,
I tend to limit this listener to localhost address only
- workers.properties
- port number in here must match the port number you set up in server.xml
- worker name in here must match the worker name you use in httpd.conf

That's pretty much it. Sorry for the lack of details, but I hope this
provides at least a checklist.

Are you seeing any error messages in any log, or are things just plain not
working without any diagnostics anywhere?
 
B

Brent

Juha,

Thanks for the checklist. I did find most of the information you
listed and I am now getting errors in my mod_jk.log file. Would you be
willing to review my config files and error message to see if you
happen to know what is wrong?

workers.properties
----------------------------------------------------------
worker.list=localtomcat

worker.localtomcat.type=ajp13
worker.localtomcat.host=localhost
worker.localtomcat.port=8080
worker.localtomcat.cachesize=50
worker.localtomcat.cache_timeout=600
worker.localtomcat.socket_keepalive=1
worker.localtomcat.reclycle_timeout=300




server.xml (snippets from Tomcat config file)
----------------------------------------------------------
<Server port="8005" shutdown="SHUTDOWN" debug="0">

<Listener
className="org.apache.jk.config.ApacheConfig"
modJk="D:/Apache2/modules/mod_jk.dll"
workersConfig="D:/Apache2/conf/workers.properties"/>

<Service name="Catalina">

<Engine
name="Standalone"
defaultHost="localhost"
debug="0"
jvmRoute="localtomcat">

<Host
name="localhost"
debug="0"
appBase="webapps"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">

<ApacheConfig
forwardAll="false"
noRoot="false"
jkDebug="info"
jkWorker="localtomcat"
configHome="D:/Apache2/"
jkLog="D:/Apache2/logs/mod_jk.log"
modJk="D:/Apache2/modules/mod_jk.dll"
jkConfig="D:/Apache2/conf/mod_jk.conf"
workersConfig="D:/Apache2/conf/workers.properties"/>

<Ajp13Connector port="8080"/>

<Listener
className="org.apache.jk.config.ApacheConfig"
append="true"
forwardAll="false"
modJk="D:/Apache2/modules/mod_jk.dll"/>

</Host>
</Engine>
</Service>
</Server>



mod_jk.config (I copied and pasted this into my Apache httpd.conf file)
----------------------------------------------------------
########## Auto generated on Wed Dec 15 14:14:20 CST 2004##########

<IfModule !mod_jk.c>
LoadModule jk_module "D:/Apache2/modules/mod_jk.dll"
</IfModule>

JkWorkersFile "D:/Apache2/conf/workers.properties"
JkLogFile "D:/Apache2/logs/mod_jk.log"

JkLogLevel debug

<VirtualHost localhost>
ServerName localhost

#################### localhost:/corpapps ####################

# Static files
Alias /corpapps "D:/tomcat5/webapps/corpapps"

<Directory "D:/tomcat5/webapps/corpapps">
Options Indexes FollowSymLinks
DirectoryIndex index.jsp index.html index.htm
</Directory>


# Deny direct access to WEB-INF and META-INF
#
<Location "/corpapps/WEB-INF/*">
AllowOverride None
deny from all
</Location>

<Location "/corpapps/META-INF/*">
AllowOverride None
deny from all
</Location>
#
# Use Directory too. On Windows, Location doesn't work unless case
matches
#
<Directory "D:/tomcat5/webapps/corpapps/WEB-INF/">
AllowOverride None
deny from all
</Directory>

<Directory "D:/tomcat5/webapps/corpapps/META-INF/">
AllowOverride None
deny from all
</Directory>

JkMount /corpapps/UploadFeedServlet localtomcat
JkMount /corpapps/SetupServlet localtomcat
JkMount /corpapps/LoginServlet localtomcat
JkMount /corpapps/*.jspx localtomcat
JkMount /corpapps/PlacementPerformanceServlet localtomcat
JkMount /corpapps/*.jsp localtomcat
JkMount /corpapps/ReconcileServlet localtomcat
</VirtualHost>



Errror Messages in mod_jk.log file
----------------------------------------------------------
[Wed Dec 15 14:25:04 2004] [jk_uri_worker_map.c (445)]: Into
jk_uri_worker_map_t::map_uri_to_worker
[Wed Dec 15 14:25:04 2004] [jk_uri_worker_map.c (459)]: Attempting to
map URI '/corpapps/main.jsp'
[Wed Dec 15 14:25:04 2004] [jk_uri_worker_map.c (539)]:
jk_uri_worker_map_t::map_uri_to_worker, Found a suffix match
localtomcat -> *.jsp
[Wed Dec 15 14:25:04 2004] [mod_jk.c (1689)]: Into handler
r->proxyreq=0 r->handler=jakarta-servlet r->notes=4983192
worker=localtomcat
[Wed Dec 15 14:25:04 2004] [jk_worker.c (90)]: Into
wc_get_worker_for_name localtomcat
[Wed Dec 15 14:25:04 2004] [jk_worker.c (94)]: wc_get_worker_for_name,
done found a worker
[Wed Dec 15 14:25:04 2004] [mod_jk.c (472)]: agsp=80 agsn=localhost
hostn=localhost shostn=localhost cbsport=0 sport=0
[Wed Dec 15 14:25:04 2004] [jk_ajp_common.c (1741)]: Into
jk_worker_t::get_endpoint
[Wed Dec 15 14:25:04 2004] [jk_ajp_common.c (1367)]: Into
jk_endpoint_t::service
[Wed Dec 15 14:25:04 2004] [jk_ajp_common.c (257)]: Into
ajp_marshal_into_msgb
[Wed Dec 15 14:25:04 2004] [jk_ajp_common.c (425)]:
ajp_marshal_into_msgb - Done
[Wed Dec 15 14:25:04 2004] [jk_connect.c (136)]: Into jk_open_socket
[Wed Dec 15 14:25:04 2004] [jk_connect.c (143)]: jk_open_socket, try
to connect socket = 1392 to 127.0.0.1:8080
[Wed Dec 15 14:25:05 2004] [jk_connect.c (159)]: jk_open_socket, after
connect ret = -1
[Wed Dec 15 14:25:05 2004] [jk_connect.c (188)]: jk_open_socket,
connect() failed errno = 61
[Wed Dec 15 14:25:05 2004] [jk_ajp_common.c (720)]: Error connecting
to tomcat. Tomcat is probably not started or is listening on the wrong
host/port (127.0.0.1:8080). Failed errno = 61
 
R

RC

Brent said:
Hi,

I'm trying to connect Apache 2.0.52 with Tomcat 5.0.28 using the mod_jk
connector, to no avail.

The documentation at
http://jakarta.apache.org/tomcat/connectors-doc/index.html only really
covers Tomcat 4.*.

Has anyone been able to do this on a Windows or Linux platform? Are
there any good resources out there that anyone knows of that I can look
to?

Very easy, I made them work on my Redhat Linux OS 7.2

1. appended a line to bottom of $APACHE2/conf/httpd.conf

LoadModule jk2_module modules/mod_jk2.so

cp the workers2.properties into $APACHE2/conf/

2. # For your *.jsp files
mkdir -p $TOMCAT5.28/webapps/your_project/jsp
# For your servlet *.class files
mkdir -p $TOMCAT5.28/webapps/your_project/WEB-INF/classes

create a web.xml file under $TOMCAT5.28/webapps/your_project/WEB-INF
see it from examples

3. start apache2 and tomcat 5
$APACHE2bin/apachectl start
$TOMCAT5.28/bin/catalina.sh start

Good luck!
 
B

Brent

Status - success!

Thanks for everyone's help. (Now the next step is clustering...ugh..I
think the trick is matching the jvmRoute Engine attribute to the load
balancing worker defined in workers.properties...or something along
those lines??)

Couple of things I'd like to mention in case anyone else needs the
information (or I forget!):

server.xml (Should look more like this)
---------------------------------------------------------------
<Server port="8005" shutdown="SHUTDOWN" debug="0">

<!--
Note I had to change the class from
org.apache.ajp.tomcat4.config.ApacheConfig to
org.apache.jk.config.ApacheConfig because the install of Tomcat I have
does not include a jar file that contains the ApacheConfig class in
that package
-->
<Listener
className="org.apache.jk.config.ApacheConfig"
forwardAll="false"
noRoot="false"
jkDebug="info"
jkWorker="localtomcat"
configHome="D:/Apache2/"
jkLog="D:/Apache2/logs/mod_jk.log"
modJk="D:/Apache2/modules/mod_jk.dll"
jkConfig="D:/Apache2/conf/mod_jk.conf"
workersConfig="D:/Apache2/conf/workers.properties"/>

<Service name="Catalina">

<!-- CONNECTOR FOR JK / AJP1.3 -->
<Connector port="8080"
enableLookups="false"
redirectPort="8443"
debug="0"
protocol="AJP/1.3"/>

<Engine
name="Standalone"
defaultHost="localhost"
debug="0"
jvmRoute="localtomcat">

<Host
name="localhost"
debug="0"
appBase="webapps"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">

<!--
Note I had to change the class from
org.apache.ajp.tomcat4.config.ApacheConfig to
org.apache.jk.config.ApacheConfig because the install of Tomcat I have
does not include a jar file that contains the ApacheConfig class in
that package
-->
<Listener
className="org.apache.jk.config.ApacheConfig"
forwardAll="false"
noRoot="false"
jkDebug="info"
jkWorker="localtomcat"
configHome="D:/Apache2/"
jkLog="D:/Apache2/logs/mod_jk.log"
modJk="D:/Apache2/modules/mod_jk.dll"
jkConfig="D:/Apache2/conf/mod_jk.conf"
workersConfig="D:/Apache2/conf/workers.properties"/>

</Host>
</Engine>
</Service>
</Server>




workers.properties (stayed the same)
---------------------------------------------------------------
worker.list=localtomcat
worker.localtomcat.type=ajp13
worker.localtomcat.host=localhost
worker.localtomcat.port=8080
worker.localtomcat.cachesize=50
worker.localtomcat.cache_timeout=600
worker.localtomcat.socket_keepalive=1
worker.localtomcat.reclycle_timeout=300




httpd.conf (copied from auto-generated mod_jk.conf file from Tomcat)
to generate from Tomcat use:
..\startup.bat -jkconfg
---------------------------------------------------------------
<IfModule !mod_jk.c>
LoadModule jk_module "D:/Apache2/modules/mod_jk.dll"
</IfModule>

JkWorkersFile "D:/Apache2/conf/workers.properties"
JkLogFile "D:/Apache2/logs/mod_jk.log"

JkLogLevel debug

<VirtualHost localhost>
ServerName localhost

# localhost:/corpapps

######
# Static files
######
Alias /corpapps "D:/tomcat5/webapps/corpapps"

<Directory "D:/tomcat5/webapps/corpapps">
Options Indexes FollowSymLinks
DirectoryIndex index.jsp index.html index.htm
</Directory>


######
# Deny direct access to WEB-INF and META-INF
######
<Location "/corpapps/WEB-INF/*">
AllowOverride None
deny from all
</Location>

<Location "/corpapps/META-INF/*">
AllowOverride None
deny from all
</Location>

######
# Use Directory too. On Windows, Location doesn't work unless case
matches
######
<Directory "D:/tomcat5/webapps/corpapps/WEB-INF/">
AllowOverride None
deny from all
</Directory>

<Directory "D:/tomcat5/webapps/corpapps/META-INF/">
AllowOverride None
deny from all
</Directory>

JkMount /corpapps/UploadFeedServlet localtomcat
JkMount /corpapps/SetupServlet localtomcat
JkMount /corpapps/LoginServlet localtomcat
JkMount /corpapps/*.jspx localtomcat
JkMount /corpapps/PlacementPerformanceServlet localtomcat
JkMount /corpapps/*.jsp localtomcat
JkMount /corpapps/ReconcileServlet localtomcat
</VirtualHost>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top