File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Apache 2.0.5.3 + Tomcat 5.5.4 connector on WinXP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Apache 2.0.5.3 + Tomcat 5.5.4 connector on WinXP" Watch "Apache 2.0.5.3 + Tomcat 5.5.4 connector on WinXP" New topic
Author

Apache 2.0.5.3 + Tomcat 5.5.4 connector on WinXP

Ravi Srinivas
Greenhorn

Joined: Sep 04, 2003
Posts: 26
Hi,
I have successfully installed Apache 2.0.5.3 and Tomcat 5.5.4 on my WinXP Pro PC. Now, I would like to install a connector between them. Reading various websites has got me a bit confused, so can anyone let me know the correct steps to go about doing this. Heres what I've got so far -

1) Most sites say mod_jk1.2 is the best connector to use as others are not being supported. For windows I'm supposed to download a mod_jk.dll but all I can find (Tomcat Connector) is a mod_jk.so file. Can I just copy that into my 'modules' folder?

2) Is there some kind of automatic set-up for the connector in Tomcat 5.5? I'm supposed to create a workers.properties file but it seems to be already created in Tomcat 5.5. Does this mean I dont have to create this? Also, what exact lines do I need to add in server.xml, most of the sites give differing commands?

3) What exact lines are to be added in the httpd.conf file on Apache side?

As you can see, I've got no clear idea on how to proceed. Is there any place with clear instructions on this with these versions of Tomcat and Apache on Windows? I expect to be working a lot on both these servers in the future so would also appreciate any links/tutorials/resources that will help.

Thanks,
Ravi
[ April 04, 2005: Message edited by: Ravi Srinivas ]
Rahul Singh Khokhar
Ranch Hand

Joined: Feb 23, 2005
Posts: 36
Hi Ravi,
The choices are plenty. I have been using mod_jk2 and found it to be very good.

Installing is easy, just follow the steps:

1. Download the mod_jk2 (for windows) from the apache's website
http://apache.ausgamers.com/jakarta/tomcat-connectors/jk2/binaries/win32/

2. Uncompress and put the module in the apache modules directory

3. There are only 2 files to configure: httpd.conf & workers2.properties

4. Add (or uncomment if already exist) the line in your httpd.conf:
loadmodule jk2_module modules/mod_jk2.dll

5. Add your uri (the tomcat context for your directories holding the jsp/servlets etc) in the workers2.properties

6. Also make sure the <connector> is defined in your tomcat web.xml with the default port no 8009 and protocol as AJP1.3

Test your application for e.g. http://localhost:8080/foldername/index.jsp
by omitting the port 8080 in your url i.e. http://localhost/foldername/index.jsp and u should be able to see the index page served by the apache using the jk2 connector.


Good Luck

regards,
Rahul..
Ravi Srinivas
Greenhorn

Joined: Sep 04, 2003
Posts: 26
Hi Rahul,
Thanks for the reply. Will try this out tomorrow and let you know.

Ravi
Ravi Srinivas
Greenhorn

Joined: Sep 04, 2003
Posts: 26

1. Download the mod_jk2 (for windows) from the apache's website
http://apache.ausgamers.com/jakarta/tomcat-connectors/jk2/binaries/win32/

I downloaded the following file from the URL - jakarta-tomcat-connectors-jk2.0.4-win32-apache2.0.49.zip On unzipping I got 3 folders (conf, doc, modules)


2. Uncompress and put the module in the apache modules directory

In the unzipped modules folder there's a file called 'mod_jk2.so'. This file I placed in the Apache modules directory


3. There are only 2 files to configure: httpd.conf & workers2.properties

Trying to update these 2 files as below...


4. Add (or uncomment if already exist) the line in your httpd.conf:
loadmodule jk2_module modules/mod_jk2.dll

Added the following line to httpd.conf - loadmodule jk2_module modules/mod_jk2.so


5. Add your uri (the tomcat context for your directories holding the jsp/servlets etc) in the workers2.properties

Didnt quite understand this.. can you give an example line?


6. Also make sure the <connector> is defined in your tomcat web.xml with the default port no 8009 and protocol as AJP1.3

Didnt quite understand this.. can you give an example line?


Test your application for e.g. http://localhost:8080/foldername/index.jsp
by omitting the port 8080 in your url i.e. http://localhost/foldername/index.jsp and u should be able to see the index page served by the apache using the jk2 connector.

My Apache is configured to run on port 8001 and Tomcat on 8080. For testing purposes I want to run the .jsp files in [TOMCAT_HOME]/webapps/jsp-examples via the Apache server. How do I do this? Do I have to copy over the .jsp files to the Apache folder?

Thanks,
Ravi
[ April 06, 2005: Message edited by: Ravi Srinivas ]
Rahul Singh Khokhar
Ranch Hand

Joined: Feb 23, 2005
Posts: 36
Ravi,
I'll take you thru the steps 5,6 & 7.

5. What I mean by URI is, the tomcat context you have defined for your java web application. In your case you just want to test only the [TOMCAT_HOME]/webapps/jsp-examples.

Log onto your Apache admin or manager page and find out the context for the examples folder. for e.g. if the context is called /jsp-examples
then add the follwing line in the workers2.properties
[uri:/jsp-examples/*.jsp]
info=Mapping JSP
group=lb

[uri:/jsp-examples/servlet/*]
info=Mapping servlets
group=lb

This lines tells the Apache thru the connector that whatever (*) is present in this context (/jsp-examples) should go to the Tomcat.
So u r ready to go for the examples folder, but for any other folder, you need to first create a Tomcat context.
If you want to learn more about context in Tomcat let me know.

6. Look at your <TOMCAT>/conf/server.xml file and in there just make sure the following lines are present
<connector>
port="8009"
protocol="AJP/1.3"
.......
</connector>

7. There is no need to move any JSPs on the Apache. Thats why we use the connector. All the JSPs reside at the Tomcat context.
Was there any specific reason to install Apache on port 8001??

Anyway, to test your connector just point to
whateveryourApacheURL/jsp-examples/whateverpage.jsp

Hope this info helps.

Rahul..
Rahul Singh Khokhar
Ranch Hand

Joined: Feb 23, 2005
Posts: 36
Also to add further, the workers2.properties will go into your <apache>/conf/ folder.
Ravi Srinivas
Greenhorn

Joined: Sep 04, 2003
Posts: 26
Hi,
I would like to know more about contexts in Tomcat, so any help there would be appreciated. I was just using port 8001 for testing.. have now switched back to port 80 (default).
I've done the steps mentioned above (added lines to workers2.properties,copied it to [APACHE]/conf, verified that server.xml contains '<Connector port="8009" enableLookups="false" protocol="AJP/1.3" />' )
But when I try to access the following -

http://localhost/jsp-examples/source.jsp

It says

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.0.53 (Win32) mod_jk2/2.0.4 Server at localhost Port 80


Any way to check if I've setup things correctly?

Thanks,
Ravi
[ April 07, 2005: Message edited by: Ravi Srinivas ]
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
I don't know if this will make a difference. But try this:

Modify your workers.properties by modifying and/or adding the following:


Then restart everything i.e. Tomcat/Apache to be on the safe side.
Try the following url to see if everything is configured okay:

web page
web page

You should see the Tomcat JSP/Servlet example pages.
Ravi Srinivas
Greenhorn

Joined: Sep 04, 2003
Posts: 26
Hi,
It seems that the reason for my 'Service Temporarily Unavailable' error was that I hadnt started the tomcat server then.. sorry abt that guys
I also needed to create an Alias in my httpd.conf file in Apache to indicate which folder /jsp-examples refers to.
Having done all that, it seems to be working fine. I can now access tje jsp-examples from Apache at the URL http://localhost/jsp-examples
So thanks a lot guys, was a real help to me. Guess I'll play around with it a bit more to get used to it.

Ravi
 
 
subject: Apache 2.0.5.3 + Tomcat 5.5.4 connector on WinXP