|
The JSF 1.2 spec Section 11.3 Specifies that the before and after phase of a Phase Listener must complete. Thus All Exceptions that occur within the Phase Listener are swallowed. Unfortunately this means that neither of the methods at http://wiki.apache.org/myfaces/Handling_Server_Errors works for these types of exceptions.
Please See http://forum.java.sun.com/thread.jspa?threadID=662657&messageID=3885082
What we have done here is Catch the Exception in the Phase Listener and Re-Direct to the Error Page. We have created an Error Handler Class that does that for us.
public class AErrorHandler {
private static final Log log = LogFactory.getLog(AErrorHandler.class); public static final String ERROR_PAGE="/errorpages/error.jsf";
public static void displayException(FacesContext _facesContext, Exception _ex) { HttpServletResponse response = (HttpServletResponse) _facesContext.getExternalContext().getResponse(); HttpServletRequest request = (HttpServletRequest) _facesContext.getExternalContext().getRequest(); try { setPageErrorData(_ex, request); response.sendRedirect(request.getContextPath()+ERROR_PAGE); _facesContext.responseComplete(); _ex.printStackTrace(); } catch (IOException ex ) { _ex.printStackTrace(); ex.printStackTrace(); } throw new AbortProcessingException("AErrorHandler: displayException() - An Error has occurred."); }
public static void setPageErrorData(Throwable _e, HttpServletRequest _request) { ErrorData errorData = new ErrorData(); errorData.setException(_e); _request.getSession().setAttribute(“errorData”, errorData); } }
Where errorData is a request Scoped Backing Bean on our Error Page
Tom
-----Original Message-----
Disclaimer: This electronic mail and any attachments are confidential and may be privileged. If you are not the intended recipient, please notify the sender immediately by replying to this email, and destroy all copies of this email and any attachments. Thank you. |

