Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch a FacesFileNotFoundException?

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>
like image 257
Benny Neugebauer Avatar asked Oct 18 '25 01:10

Benny Neugebauer


1 Answers

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.

like image 157
BalusC Avatar answered Oct 19 '25 23:10

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!