Page 1 of 1

Error handling not working

Posted: 12 Dec 2011, 11:32
by dur0
Hi, its actually a JSF thing, but maybe it has something to do with primefaces too. I use standard error handling in web.xml like this:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/pages/error.jsp</location>
</error-page>
I made a test, but its not working this way. E.g. i have a button:
<p:commandButton value="Copy" action="#{qaTool.copyJobs}"
styleClass="jobs" update="messages" />
and in the method copyJobs() i intentionally throw an uncaught exception. I'd expect to navigate to error.jsp, but instead nothing happens :-(
thanks for ideas!

Re: Error handling not working

Posted: 12 Dec 2011, 11:51
by tandraschko
The problem is the ajaxrequest. If a exception would occur on a normal request, your container error-page would work.
You could fix this with a custom JSF ExceptionHandler which redirects via

Code: Select all

facesContext.getExternalContext().redirect(...);
Also you must register then your own ExceptionHandlerFactory via your faces-config:

Code: Select all

....
	<factory>
		<exception-handler-factory>xxx.MyExceptionHandlerFactory</exception-handler-factory>
	</factory>
</faces-config>