Tuesday, July 22, 2008

Configuring Tomcat 5.5 with IIS 5 on XP

I recently set this webserver configuration up because I wanted to run GeoNetwork-Opensource alongside my other websites on IIS default port 80 rather than the GeoNetwork default port 8080. Since IIS can't serve up Java code it is necessary to use Apache Tomcat in conjunction with IIS to successfully serve GeoNetwork and other Java based applications.

*Disclaimer: I am not a Tomcat guru, I am just passing on to you what worked for me, after a couple of wasted days of searching!*

Required Files:

Apache Tomcat 5.5.26 .exe file - download here
Tomcat ISAPI Connector 1.2.14 .exe - download here
IIS 5.x - (see installation instructions below)


Installing IIS:

IIS was already installed on my machine, but for the sake of completeness...

  1. Open control panel from your start menu and select (double click) Add/remove programs.
  2. From the buttons on the left handside of the Add/remove programs window select Add/remove Windows Components.
  3. Select/tick Internet Information Services (IIS) then press the next button.
  4. Then press finish and IIS is now installed.
  5. Check IIS has successfully installed by going to http://localhost in your browser. If it has successfully worked you should see redirected to localstart.asp and see a page which informs you that your web service is now running.

Installing Tomcat 5.5:

This installer sets up Tomcat 5.5 as a windows service...

  1. Save the Tomcat-5.5.26.exe to your hard drive then double click on it to start the installer.
  2. I followed the default installation, with the exception of installing it to C:\apache\Tomcat55 simply to remove any danger of spaces causing a problem in the directory structure at a later date.
  3. Also remember to take a note of your admin password. Otherwise you will have problems at a later stage!
  4. Once installation is complete click OK to start Tomcat as a service.
  5. To check on a sccessful installation navigate to http://localhost:8080 in your browser. If it works you will see an Apache Tomcat default page informing you that " If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!"
  6. To check that Tomcat is successfully serving Java servlets and JSPs click the links to the JSP-Examples and Servlet Examples on the Tomcat default page, then execute some of the available examples.

Installing the Tomcat/IIS ISAPI Connector:

Currently if all has gone well you have IIS web server running (on its default port 80 which means you don't have to specify the port in your url ie. http://localhost ), IIS can't support Java applications. You also have Tomcat web server running on port 8080 which you do have to specify in your url - http://localhost:8080, but it can support Java applications.

The next stage is to set up an ISAPI conector so that IIS will serve up your web pages unless it is requested pages including Java servlets or .jsps from certain folders which we have defined. In these cases we want IIS to pass these requests onto Tomcat seamlessly without having to define port 8080 in the url. To do this we need to install Tomcat/IIS ISAPI conector like this...


  1. Save the isapi_redirect-1.2.14.exe to your hard drive and double click on it to start the installer.
  2. Install it to the same directory as your tomat installation (in my case C:\apache\Tomcat55).
  3. The installer automatically copies and installes the relevent files, registry settings needed for the conector. It also creates a virtual directory in IIS called jakarta which is required and also adds the new isapi_redirect.dll as an ISAPI filter for the default website also in IIS. To understand more of what is required to set the ISAPI connector up manually Please check the resources at the end of this article.
  4. Once the installation is completed, restart the Tomcat wondows service: Control panel>administration tools>services - look for and select the service called Apache Tomcat and select restart.
  5. Then restart IIS: Control panel>administration tools>Internet Information Services. Then right click on the local computer entry, select all tasks and restart IIS.
  6. Once both servers have restarted in that order view the JSP-Examples from the tomcat page again. The url should be something like http://localhost:8080/jsp-examples/ the try again removing the ":8080" like this http://localhost/jsp-examples/ - If the installation worked correctly you should be able to successfully view the examples without specifying the port:8080.
  7. To learn a little more about adding your own applications/sites to be served via Tomcat and IIS in this way view the Tomcat resources below. Or use my GeoNetwork install as an worked example (will be published shortly)...
*Note the first time I tried to run the JSP-Examples without the :8080 in the url it didn't work. On further investigation I noticed that the ISAPI filter hadn't loaded properly in IIS and was showing a red arrow. To fix this I simply opened IIS, right clicked the default website and selected properties. I clicked on the ISAPI Filters tab. The filter named jakarta showed a red down arrow. I clicked on it and pressed edit. Then re-brwosed to the ISAPI_redirect.dll which is found in my case at C:\apache\Tomcat55\bin\isapi_redirect.dll. I pressed Apply and OK. Then restarted Tomcat and IIS for good measure. The JSP-Examples then worked correctly without the :8080.

Resources:

Apache Tomcat 5.5 Official Documentation Index
Apache Tomcat Connector Official Documentation Index
Apache Tomcat Connector Official IIS How To Documentation
OnJava.com: Configuring Tomcat with IIS Web Server - Easier to read than official docs!

2 comments:

Anonymous said...

I have tried to configure Tomcat for few days, it was unsuccessfull by following different web sites. I have tried your steps in XP prof, it took less than 15 mins.. it is simple and works. Really I could not believe it.

Thank you very much for posting.

The Monkey said...

Thanks for the feedback!