Actually, it's the illegalstateexception that is recursing.
After the illegalstate exception occurs (meaning you are trying to write something to the outputstream while it is already flushed), Tomcat tries to send an errorpage to the outputstream, which causes another illegal state exception, causing Tomcat again to try and send an errorpage to the outputstream, etc. So you get 1024 illegalstateexceptions and then a stackoverflow error.
I had this problem too (tomcat 3.2.3 jdk1.4.1). I was advised to go back to jdk 1.3 (couldn't do that) or upgrade to jdk1.4.2 (didn't help). In the end I hacked the tomcat code of the handleError method in org.apache.tomcat.core.ContextManager:
if( errorLoop( ctx, req ) || errorServlet==null){
//original code, replaced by ADU according
//to
http://issues.apache.org/bugzilla/show_bug.cgi?id=19002 //errorServlet = ctx.getServletByName("tomcat.exceptionHandler");
//end original code
//start change ADU 5/11/2003
log("Error loop for " + req);
return;
//end change ADU 5/11/2003
}
That worked.