Brian Nettles
It's my blog and I share.


 

Configuring Tomcat to work with IIS

The first question is whether you should use Tomcat or Resin as your application server. Here are some quick pros and cons with each.

  • Pro for Tomcat - Third party software is more likely to run on Tomcat than Resin
  • Pro for Tomcat - Sessions don’t get lost on server restarts
  • Pro for Tomcat - Tomcat is built on open source standards and has more documentation
  • Pro for Tomcat - Tomcat is free
  • Pro for Resin - Resin is a lot easier to integrate with IIS than Tomcat

I have now set up Tomcat to work behind IIS more than once. I know the challenges that go along with it. If you miss one small item on the list that needs to be configured, your installation will fail. And the logs don’t always point you in the right direction. It truely is a challenge to make Tomcat and IIS work together, but once it does, you will be glad you did it.

1. Install Tomcat as a Windows Service
The simplest place to start is with tomcat. Make certain you download the version using the Windows installer and go ahead and install it as a service. Make certain you remove all spaces that are in your installation. After Tomcat is installed, point your browser to it at http://localhost:8080/. You should then get your Tomcat home page. Now lets get IIS to work with it prior to adding your own application to tomcat.

2. Add the Configuration and Connector Files
Create a directory in the Tomcat Home directory calle connectors. In the connectors directory, add a subdirectory for the name of your application such as “root”. Now in this connectors/root directory, add two files.

1. isapi_redirect-1.2.26.dll (or whatever the latest version is)
2. isapi_redirect-1.2.26.properties

You will need to download this isapi_redirect-1.2.xx.dll file from apache.org. Currently the url is http://tomcat.apache.org/download-connectors.cgi.

A sample of the isapi_redirect-1.2.26.properties files contains the following:

# Configuration file for the Jakarta ISAPI Redirector

# The path to the ISAPI Redirector Extension, relative to the website
# This must be in a virtual directory with execute privileges
extension_uri=/jakarta/isapi_redirect-1.2.26.dll

# Full path to the log file for the ISAPI Redirector
log_file=C:\Tomcat-5.5.25\logs\isapi_redirect.log

# Log level (debug, info, warn, error or trace)
log_level=debug

# Full path to the workers.properties file
worker_file=C:\Tomcat-5.5.25\conf\workers.properties

# Full path to the uriworkermap.properties file
worker_mount_file=C:\Tomcat-5.5.25\conf\uriworkermap.properties

Now we have two more configuration files to add. These two you should place in the conf directory:

1. workers.properties
2. uriworkermap.properties

A sample of the workers.properties is given below:

# 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

A sample of the uriworkermap.properties is given below:

/*=worker1
!/images/*=worker1
!*.jpg=worker1
!*.xmls=worker1
!*.gif=worker1
!*.bmp=worker1

For more information on these two files, search the following two urls:
http://tomcat.apache.org/connectors-doc/reference/workers.html
http://tomcat.apache.org/connectors-doc/reference/uriworkermap.html

3. Make the Registry Entries
Follow the example on this image by going into clicking start -> run -> regedit and the entries just like on this image. Click on the image to get a larger view of it.
Windows Registires

4. Configure IIS
Before you do anything with IIS, make certain you can see your web pages without interference from tomcat. Start by turning Tomcat and create a website and point it to the ROOT directory in the webapps directory of Tomcat. See if you can see the images when referencing them direct by url. ex. http://localhost/tomcat.gif. If you see the image, then you know IIS is working.

a. Add a new application pool that is copied from the default application pool.

 

b. Add a webservice extension and point it to the connectors.

c. Add a jakarta virtual directory

d. Make certain that every reference in this website to the application pool all point to the same newly created application pool.

e. Setup the isapi filter by calling it jakarta and point it to the isapi_redirect-1.2.26.dll file. After doing so, restart IIS and make certain you have a green arrow in place for the filter.
ISAPI Filters

Now try the url http://localhost without the reference to port 8080. If you see the default Tomcat application, you are in business.

5. Add your own application
Turn off Tomcat and rename the ROOT directory ROOT_ORIGINAL. Now recreate the ROOT folder and add your application into the ROOT directory. Now you can restart Tomcat, Restart IIS and check to see if your application shows up at http://localhost

If it doesn’t work, carefully check all of your settings.

6. Heap Size
Sometimes, your newly established application ends up running out of memory and therefore you need to adjust the heap size. This is done in the registries. Take a look at the image here. You may need to add a couple of entries to the registries as displayed here.

2 Responses to “Configuring Tomcat to work with IIS”
  1. Ephraim Freed Says:

    Hi Brian- Thanks for this post!

    Do you know if this setup works with multipler verions of both Tomcat and IIS? Does it work for Tomcat 6.0? Does it work with IIS6? What about IIS7?

    Thanks. -Ephraim

  2. Brian Nettles Says:

    I have used this setup with both Tomcat 5 and Tomcat 6. This example is done using IIS6. As of yet, I have not tested it in IIS7. If anyone else out there has set up tomcat to work with IIS7, please let the rest of us know how it went.

Leave a Reply


Blog Information Profile for Supertramp678