In our project we are using PrimeFaces 3.3 along with OmniFaces FullAjaxExceptionHandler
as described in this blog.
It works very well for all Ajax calls, except for exceptions in our implementation of the load()
method in the class that extends PrimeFaces LazyDataModel
. After an exception is thrown in the load()
method, it's not showing up in the iterator in the handleAjaxException()
method of the FullAjaxExceptionHandler
class:
Iterator<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = getUnhandledExceptionQueuedEvents().iterator();
All other exceptions thrown in Ajax calls end up in the iterator.
I compared stack traces and that's what I found: when using PrimeFaces lazy loading, the stack trace shows that it occurred during render response phase:
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:391)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
Non-lazy loading errors occur during invoke application phase:
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
I have the following questions:
- Is the reason that
FullAjaxExceptionHandler
doesn't catch the exception because it is thrown too late in the lifecycle? - Is it a PrimeFaces bug?