Wednesday, June 23, 2010

Hard to Debug Tomcat JK Connector Problem

If you try to open a page in Liferay (or any J2EE app) and only see "The data area passed to a system call is too small", chances are you're using IIS and the Tomcat IIS Connector library in front of your J2EE server.  The problem is that the url is too long.  Because Liferay uses the longest urls in the universe I had a similar problem with the Pound reverse proxy, but at least Pound told me what the problem was in the error message ("Error: request URL too long" or something like that).  Naturally, you won't get messages about this in your logs because the request gets stopped before tomcat even sees it.

Here is a mailing list thread about this from 2009.  Basically, it looks to me like the apache guys are misinterpreting the variable INTERNET_MAX_URL_LENGTH from WinInet.h as including the maximum query string length when it is only intended to represent the url before the query string (the protocol, the "://" protocol/domain/path seperator, and the path).  So urls which are valid for IIS can have really long query strings which cause them to break isapi_redirect.dll.  I fixed this by adding a macro (#define ISAPI_MAX_URL_LENGTH 4096) then replacing every occurrence of INTERNET_MAX_URL_LENGTH with ISAPI_MAX_URL_LENGTH and it appeared to work fine.  I'm not a security expert though, I might have opened an exploitable hole.  Point is, it works better now.

If you're not using IIS, I have no idea.

No comments: