Re: Error 500 with stack trace

Keith Fetterman <[email protected]> Wed, 03 May 2006 07:50:22 -0700
Newsgroups gmane.text.xml.resin.user
Organization Mariner Supply, Inc.
Message-ID <[email protected]>
This problem is also affecting us on a daily basis. The problem makes it 
  difficult to troubleshoot. We also use a servlet to log errors.

We have a general catch all error logging servlet, which catches and 
logs the "java.lang.IllegalStateException: forward() not allowed after 
buffer has committed." But, we have a different problem. The exception 
that caused the problem is not written to the log or not enough of the 
stack trace is written into the log.  The error that caused the problem 
is nested twice, first in an IllegalStateException and then in a 
ServletException. When displaying the stack trace, the real cause is at 
the bottom, which is not printed. Instead, I see " ... 16 more".  Here 
is an example.

javax.servlet.ServletException: Exception occurred during checkout
         at 
com.marinersupply.servlet.actions.CheckOut.doAction(CheckOut.java:129)
         at com.marinersupply.servlet.Control.service(Control.java:177)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
         at 
com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:99)
         at 
com.marinersupply.common.servlet.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:37)
         at 
com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
         at 
com.marinersupply.common.servlet.HTTPSRedirectFilter.doFilter(HTTPSRedirectFilter.java:183)
         at 
com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
         at 
com.caucho.server.security.SecurityFilterChain.doFilter(SecurityFilterChain.java:135)
         at 
com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:175)
         at 
com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163)
         at 
com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:208)
         at 
com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:396)
         at com.caucho.server.port.TcpConnection.run(TcpConnection.java:363)
         at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:490)
         at com.caucho.util.ThreadPool.run(ThreadPool.java:423)
         at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalStateException: forward() not allowed after 
buffer has committed.
         at 
com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:139)
         at 
com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:106)
         at 
com.marinersupply.servlet.actions.CheckOut.doAction(CheckOut.java:127)
         ... 16 more

We are using Log4J.  Maybe there is a way to change the stack trace 
printing behavior?  I just now thought of that.  dah...


Mattias Jiderhamn wrote:
> This has caused us some trouble, since we have the error logging in an 
> "error servlet". Even if the error message cannot be shown in the 
> browser, we want the error to be logged.
> 
> At 2006-05-03 08:02, you wrote:
>> Hi,
>>  
>> I've noticed that there's a difference on how Resin 3 handles 
>> errorpage-things compared to Resin 2. It seems that if there is an 
>> error in your JSP after something is already written to the response 
>> and its buffer has been committed, the errorpage cannot be shown 
>> anymore via the forward mechanism. This is propably what the spec 
>> expects, but Resin 2 didn't work like this...
>>  
>> -Kai
>>
>> ------------------------------------------------------------------------
>> *From:* [email protected] [ 
>> mailto:[email protected]] *On Behalf Of *Gary Wells
>> *Sent:* 2. toukokuuta 2006 21:33
>> *To:* [email protected]
>> *Subject:* RE: Error 500 with stack trace
>>
>> To clarify my two questions further…
>>
>>  
>>
>> 1) How do you get the custom error 500 page to display? I’ve got the 
>> following in my web.xml:
>>
>>  
>>
>> <error-page>
>>
>>     <error-code>500</error-code>
>>
>>     <location>/500.jsp</location>
>>
>>   </error-page>
>>
>>  
>>
>> … but when an 500 error is thrown I get the following error message:
>>
>>  
>>
>> java.lang.IllegalStateException: forward() not allowed after buffer has
>>
>> committed.
>>
>> at 
>> com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:139)
>>
>> at 
>> com.caucho.server.webapp.RequestDispatcherImpl.error(RequestDispatcherImpl.java:113)
>>
>> at 
>> com.caucho.server.webapp.ErrorPageManager.sendServletError(ErrorPageManager.java:363)
>>
>> at 
>> com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:180)
>>
>> at 
>> com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
>>
>> at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
>>
>> at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389)
>>
>> at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:492)
>>
>> at com.caucho.util.ThreadPool.run(ThreadPool.java:425)
>>
>> at java.lang.Thread.run(Thread.java:613)
>>
>>  
>>
>>  
>>
>> 2) How do you gain access to the stack trace of the original exception 
>> so it can be displayed?
>>
>>  
>>
>>  
>>
>> Thanks – G
>>
>>  
>> ------------------------------------------------------------------------
>> *From:* Gary Wells [ mailto:[email protected]]
>> *Sent:* Tuesday, May 02, 2006 10:51 AM
>> *To:* '[email protected]'
>> *Subject:* Error 500 with stack trace
>>
>>  
>>
>> Does anybody know how to setup Resin with a custom page for an error 
>> 500 that displays the stack trace?
>>
>>  
>>
>> Thanks – G