I am trying to create a filter to handle exceptions (see Handling Uncaught Exception in JSF)
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
try {
log.info("check filter is running");
chain.doFilter(request, response);
} catch (Exception e) {
log.error("Uncaught exception",e);
request.setAttribute("exception", e);
request.getRequestDispatcher("/error.xhtml").forward(request, response);
}
}
I execute the following method:
<p:commandButton value="Dispatch Order" update="@form"
action="#{orderBean.dispatchOrder()}">
</p:commandButton>
However, no exception is handled.
I see the error in the logs:
May 21, 2013 6:04:32 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: #{orderBean.dispatchOrder()}: MyException.....
What am I doing wrong?