JSF custom page for unhandled exception not working

Newbie Source

I have followed several online materials to implement custom exception handler for my JSF application. I have added


into my web.xml, and try it with the following code

FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().responseSendError(400, "Testing 400 message");

It works flawlessly with any kind of server error code. But it doesn't work for the unhandled exception such as RuntimeException. I try to throw an exception

throw new RuntimeException();

by a button clicked on UI, the exception is thrown, but it doesn't redirect to my custom error page /error.xhtml. What could be the reason? Did I missed any configuration? I have also tried to add


into web.xml but still not working. Any idea?



comments powered by Disqus