Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Apache / Tomcat mod_jk Issue |
|
Author |
|
tk
Joined: 27 Jun 2006 Posts: 10
|
Posted: Tue 27 Jun '06 10:08 Post subject: Apache / Tomcat mod_jk Issue |
|
|
I know you guys must get really tired of these questions, but I've read through everything I can find and still haven't figured this one out. Of course, I can't rule out the possibility that I've read so much, sometimes contradictory, material that now I'm completely lost. Anyway, here goes...
I am trying to install Apache 2.2 and Tomcat 5.5 on a Windows XP Home PC. Basically I'm trying to learn JSP and Servlets and just need a test environment. Ok, so the Apache install went off without a hitch... surprisingly easy actually, and now when I pull up http://localhost I get whatever index page I put in my htdocs folder. Next I installed Tomcat 5.5. That actually went very well also. The only change I made to the server.xml files was to change the port to 1642. So now, I can pull up http://localhost and get the apache home page, or I can pull up http://localhost:1642 and get the tomcat homepage. I tried the .jsp examples that came with tomcat and they all work as well so that much is taken care of.
I installed mod_jk.... which was a drama in and of itself. Anyway, it is installed and after a frightening number of attempts to edit httpd.config I finally have that working with Apache. Just... not with Tomcat. I have edited the server.xml file about fifteen times as per the fifteen or so different tutorials out there. Each time I get the same result, which is sweet f.a. Whenever I put a .jsp page inside my htdocs folder I get a 503 service unavailable error. I've tried stopping, starting, restarting the severs after each attempt to edit server.xml, but nothing seems to work. So now I have basically put the server.xml back to it's original state, with the exception of having changed the port to 1642 and the <Engine> statement from the jakarta website. Neither the Apache nor the Tomcat error log shows anything wrong, it's just not forwarding the .jsp to Tomcat, or not finding it, or whatever.
Below are the changes I made to httpd.config
LoadModule jk_module modules/mod_jk.so
JkWorkersFile "C:/dev/Apache Software Foundation/Tomcat 5.5/conf/workers.properties"
JkLogFile "C:/dev/Apache Software Foundation/Tomcat 5.5/logs/mod_jk.log"
JkLogLevel info
JkMount /manager ajp13
JkMount /manager/* ajp13
JkMount /examples ajp13
JkMount /examples/* ajp13
JkMount /tomcat-docs ajp13
JkMount /tomcat-docs/* ajp13
JkMount /webdav ajp13
JkMount /webdav/* ajp13
JkMount /*.jsp ajp13
When I check my mod_jk log on Tomcat this is what I'm getting:
[Tue Jun 27 03:53:46 2006] [info] jk_ajp_common.c (889): Failed opening socket to (127.0.0.1:8009) with (errno=61)
[Tue Jun 27 03:53:46 2006] [info] jk_ajp_common.c (1248): Error connecting to the Tomcat process.
[Tue Jun 27 03:53:46 2006] [info] jk_ajp_common.c (1749): Sending request to tomcat failed, recoverable operation attempt=3
[Tue Jun 27 03:53:46 2006] [error] jk_ajp_common.c (1758): Error connecting to tomcat. Tomcat is probably not started or is listening on the wrong port. worker=ajp13 failed
[Tue Jun 27 03:53:46 2006] [info] mod_jk.c (1985): Service error=0 for worker=ajp13
Anything that even remotely resembles help would be greatly appreciated at this point. |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3093 Location: Hilversum, NL, EU
|
Posted: Tue 27 Jun '06 10:31 Post subject: |
|
|
Looks Apache is not finding Tomcat on port 8009.
I am not using Tomcat anymore, but when I recall you have to put a workers.properties file in your Apache/conf dir which conatains minimal:
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.reclycle_timeout=300
You must point to this file in httpfconf:
JkWorkersFile "x:/........./conf/workers.properties"
Why not try the new connector in Apache 2.2 ?
See http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html
Steffen |
|
Back to top |
|
tk
Joined: 27 Jun 2006 Posts: 10
|
Posted: Tue 27 Jun '06 19:58 Post subject: |
|
|
Steffen,
Thanks for the response. I went back and forth with the workers.properties file. Some tutorials said it has to be in the Apache/conf directory, and others said it had to be in the Tomcat/conf directory. At present I have it in Tomcat/conf, but either way the file has been there. I'm a little confused on the port issue. I've looked through httpd.config and can't find any listing where Apache sets the port. Obviously I can set it in Tomcat's server.xml file, but I'm a little confused. If I set it to 8080 rather than 1642 aren't I then just using Tomcat for all requests rather than as a java container? I would prefer to have apache handle .html, .php etc.
As for mod_proxy.... I was looking to migrate to that eventually but am a little raw w/ Apache to pull if off I think. The Jakarta section on mod_proxy is pretty clear about making sure your server is secure before you use it, and I honestly have no idea how to pull that off. |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3093 Location: Hilversum, NL, EU
|
Posted: Tue 27 Jun '06 20:48 Post subject: |
|
|
There are two workers.properties files, one in the Apache/conf and one in the Tomcat/conf. They are different files. And normaly you do not have to change the file in tomcat/conf.
ajp13 is sending listening on port 8009 (the AJP 1.3 Connector port), do not change that port in the server.xml. This port is not the 8080 or 1642 you mention.
Btw. I am afraid that I cannot not help you that much, this because it was a long time ago that i was running Tomcat with mod_jk.
Steffen |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3093 Location: Hilversum, NL, EU
|
Posted: Tue 27 Jun '06 21:25 Post subject: |
|
|
tk wrote: | As for mod_proxy.... I was looking to migrate to that eventually but am a little raw w/ Apache to pull if off I think. The Jakarta section on mod_proxy is pretty clear about making sure your server is secure before you use it, and I honestly have no idea how to pull that off. |
Enable mod_proxy_ajp and mod_proxy
And eg for the tomcat examples:
ProxyPass /examples ajp://127.0.0.1:8009/examples
That's all,
Steffen |
|
Back to top |
|
|
|
|
|
|