Wednesday 7 February 2007

Linking IIS to Tomcat 5.5 on Windows XP

Just today, I had to link IIS to Tomcat 5.5. I had done this for quite a few years. It was an interesting experience. I will attach some useful links below, but first a word of advice :

The Tomcat Connectors web site says that the jk2 connector is deprecated because of a lack of interest and advices everyone to use the jk1.2 connector. I spent approximately 3-4 hours on the jk1.2 connector with Tomcat 5.5.20 and IIS 5.1 on XP and could not make it work. Rechecked multiple times and everything was configured exactly as the documentation suggested but IIS would not forward to Tomcat.

Gave up and went to the JK2 connector and configured it according to the documentation and voila it worked on the first go.

Below is a good link to link Tomcat with IIS. The only changes I have done from this guide is using the latest Tomcat (5.5.0), JDK 1.5 and I used IIS 5.1 on XP.

Broad Steps are :
1. Install IIS. Test independently.
2. Install JDK.
3. Install Tomcat. Test independently.
4. Setup environment variables JAVA_HOME and CATALINA_HOME in "Control Panel -> System" in your Windows configuration. The former should point to where Java is installed and the later to where Tomcat is installed.
5. Now, Stop Tomcat and IIS services.
6. Edit workers2.properties in your /conf directory to have values that match your environment and installation directories. My example one is below.
7. Restart Tomcat.
8. Install the following configuration entries into the Windows registry. Edit the entries to match your environment.
[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\2.0]
"workersFile"="c:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\conf\\workers2.properties"
"extensionUri"="/jakarta/isapi_redirector2.dll"
"logLevel"="debug"
"serverRoot"="c:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\"


9. Install the Tomcat connector as an ISAPI filter.
(a) Go to your IIS manager and right click on your web site and go to properties.
(b) Select ISAPI filters
(c) Add one, give it a name, any name and then browse to the location where you unpacked the isapi_redirector2.dll and select it.
(d) Save.

10. Create a virtual directory on your website, call it "jakarta" and then point it to the directory where your isapi_redirector2.dll is installed. Give it execute permission.

11. Restart (start) IIS. For good measure, start the WWW service in the "services" screen of your control panel and ensure that your "default web site" is running.

12. Test. http://localhost/servlets-examples/

It should work. Good luck

workers2.properties File
info=Shared memory file. Required for multiprocess servers
file=C:\Program Files\Apache Software Foundation\Tomcat 5.5\work\jk2.shm
size=1000000

[channel.socket:localhost:8009]
info=Ajp13 worker, connects to tomcat instance using AJP 1.3 protocol
tomcatId=localhost:8009

[uri:/jsp-examples/*]
info=JSP examples, map requests for all JSP pages to Tomcat.
context=/jsp-examples

[uri:/servlets-examples/*]
info=Servlet examples, map requests for all servlets to Tomcat.
context=/servlets-examples


This is the link which I found useful. It does deal with IIS 6 which is available only on Windows Server 2003. Just use the steps above for IIS 5
Linking IIS 6.0 to Tomcat.

2 comments:

Unknown said...

Thanks dude.
All tutorials should be nice, quick and clear like that.

bman said...

I just finished a project that entailed creating a connector between IIS and Apache Tomcat using .net managed code.

The project has an included installer that makes it easier to run through the process. You can get this up and running quickly.

http://tomcatiis.riaforge.org

Best,
B.