myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Beatriz Martinez <>
Subject Handline server errors FAILs when the exception is raised during RenderResponse
Date Wed, 17 Jun 2009 09:48:39 GMT

I'm using MyFaces 1.2.6, Tomahawk12-1.1.8 and Tomcat 6.0.

I have followed the instructions given at "",
specially the solution at "Using Servlets", but I am unable to redirect the user to an error
page when a "ServletException" is raised while the JSP page is being rendered.

Let me go in more detail:

- I've disabled the MyFaces ERROR HANDLING in the web.xml.
- I've created a wrapper class of the FacesServlet (as by,
catching any exceptions, and redirecting the Response to an error page (whatever kind of,
even a plain HTML page).

- The FacesServlet goes through the lifecycle, and finally enters in the phase RENDER RESPONSE.
The corresponding JSF page starts being rendered (UIcomponent by UIcomponent, method "actuallyRenderView"
of "JspViewHandlerImpl" class). Everything goes well until it reaches a component that uses
a value from a managed bean (scope "request"). 
This is the first time the managed bean is referred, so it instantiates it (calling the constructor,
and the appropiate setters). There is an error in one of the setters, and the method raises
a "ServletException".
The exception is escalated (wrapped and thrown) until it reaches the FacesServletWrapper,
where it gets catched.
There the "response.sendRedirect" is called, but FAILS, because it says that the Response
has been already committed.

The same happens using "default handler" or "plain JSP" solutions.

I did some debugging and found out that everytime a UIcomponent is rendered, the method "encodeEnd"
is being called, and this method performs a "writer.flush()" call, which commits the response.
From my point of view, that means that once the page has started to being rendered, whatever
exception appears, it cannot be handled properly, and we get an incomplete JSP displayed in
the client, and exception traces in the logs, but there is not an "elegant" way to inform
the user that an error has happened.

Am I missing or overlooking something?
Is there a way that I have not tried that allows a developer to deal with exceptions raised
while rendering?

Thanks a lot in advance,

View raw message