How to catch a FacesFileNotFoundException?

How can i catch

com.sun.faces.context.FacesFileNotFoundException

in a Java EE web application?

I tried this with the following lines in the web.xml file, but I was not successful:

  ...
  <error-page>
    <error-code>404</error-code>
    <location>/404.jsf</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/404.jsf</location>
  </error-page>
  <error-page>
    <exception-type>FacesFileNotFoundException</exception-type>
    <location>/404.jsf</location>
  </error-page>
  <error-page>
    <exception-type>FileNotFoundException</exception-type>
    <location>/404.jsf</location>
  </error-page>
  <error-page>
    <exception-type>FailingHttpStatusCodeException</exception-type>
    <location>/404.jsf</location>
  </error-page>
</web-app>
+3
source share
1 answer

You need to specify FQN (fully qualified name), and not just N as an exception type.

<exception-type>com.sun.faces.context.FacesFileNotFoundException</exception-type>

Alternatively, if you are already using OmniFaces , register it FacesExceptionFilterand then FacesFileNotFoundExceptionwill be treated as 404.

+6
source

All Articles