aspose file tools*
The moose likes Tomcat and the fly likes Tomcat Apache connector - beginner's question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat Apache connector - beginner Watch "Tomcat Apache connector - beginner New topic
Author

Tomcat Apache connector - beginner's question

sam chow
Greenhorn

Joined: Nov 15, 2010
Posts: 6
I am trying to set the connector between Tomcat and Apache
Tomcat handles jsp and the rest by Apache

I used mod_jk-1.2-31-httpd-2.2.3.so and follow all the steps based on the posts I have read
include:Load Module, workers.properties, modify httpd.conf and server.conf(Tomcat)

ps: Tomcat port 8080, Apache port 80
but somehow I don't get the right thing when I type http://172.0.0.1/jsp/myjsp.jsp
work only if I type http://172.0.0.1:8080/jsp/myjsp.jsp

the error log shows me that the Apache is still reading the files from Apache folder (Apache2.2/htdocs) but I want (Tomcat 7.0/jsp) instead

I am not sure where I made a mistake, some direction is needed

Thanks everyone

Sam
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Have you check mod_jk log?
sam chow
Greenhorn

Joined: Nov 15, 2010
Posts: 6
mod_jk.log file:

[Tue Nov 16 12:51:44.024 2010] [1988:1976] [info] jk_open_socket::jk_connect.c (626): connect to 127.0.0.1:8009 failed (errno=61)
[Tue Nov 16 12:51:44.024 2010] [1988:1976] [info] ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening socket to (127.0.0.1:8009) (errno=61)
[Tue Nov 16 12:51:44.024 2010] [1988:1976] [error] ajp_send_request::jk_ajp_common.c (1578): (tomcat1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=61)
[Tue Nov 16 12:51:44.024 2010] [1988:1976] [info] ajp_service::jk_ajp_common.c (2543): (tomcat1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)
[Tue Nov 16 12:51:45.131 2010] [1988:1976] [info] jk_open_socket::jk_connect.c (626): connect to 127.0.0.1:8009 failed (errno=61)
[Tue Nov 16 12:51:45.131 2010] [1988:1976] [info] ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening socket to (127.0.0.1:8009) (errno=61)
[Tue Nov 16 12:51:45.131 2010] [1988:1976] [error] ajp_send_request::jk_ajp_common.c (1578): (tomcat1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=61)
[Tue Nov 16 12:51:45.131 2010] [1988:1976] [info] ajp_service::jk_ajp_common.c (2543): (tomcat1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Tue Nov 16 12:51:45.131 2010] [1988:1976] [error] ajp_service::jk_ajp_common.c (2562): (tomcat1) connecting to tomcat failed.
[Tue Nov 16 12:51:45.131 2010] [1988:1976] [info] jk_handler::mod_jk.c (2627): Service error=-3 for worker=tomcat1


and here is my workers2.properties file:
worker.list = controller,tomcat1,tomcat2

worker.tomcat1.port=8009
worker.tomcat1.host=127.0.0.1
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor = 3

worker.tomcat2.port=9009
worker.tomcat2.host=127.0.0.1
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor = 2

worker.controller.type=lb
worker.controller.balanced_workers=tomcat1,tomcat2
worker.controller.sticky_session=1

[logger]
level=DEBUG

[config:]
file=C:/Program Files/Apache Software Foundation/Apache2.2/conf/workers2.properties
debug=0
debugEnv=0

[shm:]
file=C:/Program Files/Apache Software Foundation/Apache2.2/logs/jk2.shm
size=1000000
debug=0
disabled=0

[workerEnv:]
info=Global server options
timing=1
debug=0

[channel.socket:localhost:8009]
debug=0
tomcatId=tomcat1

[uri:/jkstatus/*]
group=status:

[uri:/jsp/*.jsp]
context=/jsp
tomcat1 = ajp13:localhost:8009
debug=0

workers.tomcat_home = "C:/Program Files/Apache Software Foundation/Tomcat 7.0"
workers.java_home = "C:/Program Files/Java/jdk1.6.0_22"


not really sure what the problem is

sam
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
sam chow wrote:
[Tue Nov 16 12:51:44.024 2010] [1988:1976] [info] jk_open_socket::jk_connect.c (626): connect to 127.0.0.1:8009 failed (errno=61)
[Tue Nov 16 12:51:44.024 2010] [1988:1976] [info] ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening socket to (127.0.0.1:8009) (errno=61)
[Tue Nov 16 12:51:44.024 2010] [1988:1976] [error] ajp_send_request::jk_ajp_common.c (1578): (tomcat1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=61)


Looks like Tomcat is not listening on port 8009. Perhaps there are some mistakes, misprints in server.conf.

I would suggest you to start with more light scenario without load balancing, sticky sessions and so on. Make the simplest configuration work and then go to the more complex scenarios.
sam chow
Greenhorn

Joined: Nov 15, 2010
Posts: 6
but I only add few lines of code in server.xml

<Context path = "/jsp"
docBase = "C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/jsp"
debug = "0"
reloadable = "true"
crossContext = "true">
</Context>

but thanks a lot for your help, I'd better start from simple scenario
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
You need to have something like



in server.xml
sam chow
Greenhorn

Joined: Nov 15, 2010
Posts: 6
finally I get this working now

figure out that I miss that line
<Connector port = "8009" protocol= "AJP/1.3" redirectPort = "8443"/>


thank you very much for your help
sam chow
Greenhorn

Joined: Nov 15, 2010
Posts: 6
right now I am working on setting up some virtual host
ie: virtual1.name.com and virtual2.name.com

so based on the tutorials I read

I modified three files:
-----Apache files------
worker2.properties:
worker.connect_id.port=8112
worker.connect_id.host=192.168.1.1
worker.connect_id.type=ajp13

httpd.conf:
<VirtualHost 192.168.1.1>
ServerAdmin admin@name.com
DocumentRoot "C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/virtualhost"
ServerName "virtual1.name.com:80"
<Directory "C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/virtualhost/cgi-bin">
Options ExecCGI
SetHandler cgi-script
</Directory>
JkMount /servlet/* connect_id
JkMount /*.html connect_id
JkMount /*.jsp connect_id
</VirtualHost>

----Tomcat----
myserver.xml
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8112" minProcessors="3" maxProcessors="10"
acceptCount="10" debug="0"/>
<Host name="virtual1.name.com" debug="0" unpackWARs="true">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="virtual_log." suffix=".txt" timestamp="true"/>
<Context path="" docBase="C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/virtualhost" debug="0" reloadable="true"/>
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="virtual_log." suffix=".txt"
pattern="common"/>
</Host>


what am I missing?

the question is that it is always working if I type
http://127.0.0.1:8112/virtualhost/index.html (Tomcat folder can be found)

never work for
http://192.168.1.1 or http://virtual1.name.com


some help please?
sam chow
Greenhorn

Joined: Nov 15, 2010
Posts: 6
please help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat Apache connector - beginner's question