Available since OmniFaces 1.0

The FacesExceptionFilter will solve 2 problems with exceptions thrown in Faces methods.

  1. Mojarra's FacesFileNotFoundException needs to be interpreted as 404.
  2. Root cause needs to be unwrapped from FacesException and ELException to utilize standard Servlet API error page handling.

Noted should be that this filter won't run on exceptions thrown during ajax requests. To handle them using web.xml configured error pages, use FullAjaxExceptionHandler.

Since version 3.2, the FacesExceptionFilter also logs exceptions with an UUID and IP via the logException(HttpServletRequest, Throwable, String, String, Object...) method. The UUID is in turn available in EL by #{requestScope['org.omnifaces.exception_uuid']}.


To get it to run, map this filter on an <url-pattern> of /* in web.xml.


Error pages

Please refer the "Error pages" section of the FullAjaxExceptionHandler javadoc for recommended error page configuration.


Please refer the "Configuration" section of the FullAjaxExceptionHandler javadoc for available context parameters.

Customizing FacesExceptionFilter

If more fine grained control is desired for logging the exception, then the developer can opt to extend this FacesExceptionFilter and override one or more of the following protected methods:


The FacesExceptionFilter is also configured on this showcase application. To see the proper handling of 404 yourself, try entering a random URL matching the *.xhtml URL pattern of the FacesServlet on this showcase web application. For example, thisdoesnotexist.xhtml. To see the proper handling of FacesException yourself, invoke the "normal request" buttons on the FullAjaxExceptionHandler showcase page. Without the filter, the RuntimeException and SQLException would end up in an generic HTTP 500 error page instead of the one specific to the exception.