How can I catch a
com.sun.faces.context.FacesFileNotFoundException
in a Java EE web application?
I tried it with adding the following lines in my 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>
You need to specify the FQN (Full Qualified Name), not just the N as exception type.
<exception-type>com.sun.faces.context.FacesFileNotFoundException</exception-type>
Alternatively, if you already happen to use OmniFaces, register its FacesExceptionFilter
and then the FacesFileNotFoundException
will be handled as 404.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With