Tuesday, April 05, 2011

IIS7 hiding tomcat webapp error pages

Keywords:
IIS IIS7 custom error pages hiding masking tomcat 500 webapp error page jk connector AJP

Problem:
With tomcat integrated into IIS7 using the jk connector error pages from the webapp that have the http-response status set (eg to 500) get "replaced" with a generic IIS custom error page:
500 - Internal server error. 
There is a problem with the resource you are looking for, and it cannot be displayed


A quick web-search reveals it's a common issue for ASP.NET developers and the solution is simply to make changes to the ASP.NET application config or in code setting a special HttpResponse.TrySkipIisCustomErrors property(!) ... but what are the options for when the pages are being supplied by an ISAPI redirector/plugin (i.e. the JK connector in this case)?

Solution:
Based on the detailed notes on the IIS Blog (What to expect from IIS7 custom error module) the minimal steps required seem to be the following:

Step 1: create a Web.config file in the root folder of the Web Site


This is the Web Site where you've configured the "jakarta" virtual directory. If it's "Default Web Site" this may be C:\inetpub\wwwroot but check the properties to be sure (Right click Web Site > Manage Web Site > Advanced Settings ... and note the setting for 'Physical Path').

Step 2: add configuration to the Web.config file


<configuration>
   <system.webServer>
      <httpErrors errorMode="Detailed" existingResponse="Auto" />
   </system.webServer>
</configuration>


Step 3: restart the web site


Eg Right click Web Site > Manage Web Site > Restart


Be sure to to test this on the local machine (where IIS7 is installed) and from another machine in the network as IIS may give different error-page behaviour for local and 'remote' requests.

1 comment:

Anonymous said...

Do you have the same issue when you use the .net based connectors (http://tomcatiis.riaforge.org)?
These do not use virtual directories ?