Hi,
I've got a JSF (2.02-10) app on a GlassFish v3 stack and am trying to direct a
user defined exception thrown by an action listener to an error page defined in the
web.xml file. What happens is that the default HTTP 500 error page is navigated
to instead of the page that I have specified.
web.xml extract
-----------------------
<error-page>
<exception-type>uk.co.myco.exceptions.MyTestException</exception-type>
<location>/faces/errorPage.xhtml</location>
</error-page>
My exception declaration
-------------------------------------
public class MyTestException extends Exception { ... constructors... }
Just to test this functionality I added an h:commandButton to a JSF page which
calls an action listener which throws the MyTestException as follows:
public String testExceptionAction() throws MyTestException {
throw new MyTestException("hello");
}
I get the default GlassFish HTTP 500 error page as shown:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: uk.co.myco.exceptions.MyTestException
root cause
javax.faces.el.EvaluationException: uk.co.myco.exceptions.MyTestException
root cause
uk.co.myco.exceptions.MyTestException
note The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.
--------------------------------------------------------------------------------
It's as if the Faces Servlet is catching my MyTestException and re-throwing a
ServletException. Can anyone suggest what I should be doing to get this working?
If I change the <exception-type> entry in web.xml to either ServletException OR
EvaluationException then the page I have specified is navigated to successfully.
Thanks for any suggestions, this problem has been hanging around on my "not
working right" list for a while now and it'd be nice to put a solid workaround in
place (i.e. changing the default error pages) if this functionality just doesn't work.
Regards,
Brendan.
[Message sent by forum member 'healeyb']
http://forums.java.net/jive/thread.jspa?messageID=469334