Re: [solved] Exception handling JSF2

Splash Forums PrettyFaces Users [solved] Exception handling JSF2 Re: [solved] Exception handling JSF2

#20137

0swald
Participant
java.lang.NullPointerException
at com.ocpsoft.pretty.PrettyContext.getCurrentInstance(PrettyContext.java:68)
at com.ocpsoft.pretty.faces.application.PrettyRedirector.redirect(PrettyRedirector.java:51)
at com.ocpsoft.pretty.faces.application.PrettyNavigationHandler.handleNavigation(PrettyNavigationHandler.java:49)
at com.mycompany.web.faces.CustomErrorExceptionHandler.handle(CustomErrorExceptionHandler.java:44)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
...
...

Not sure it’s a bug. When using redirect() instead of nav handler like that

fc.getExternalContext().redirect("/faces/pages/index.xhtml");
fc.responseComplete();

I also get Exception:

java.lang.NullPointerException
at com.sun.faces.context.flash.ELFlash.doLastPhaseActions(ELFlash.java:589)
at com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:555)
at com.mycompany.web.faces.CustomErrorExceptionHandler.handle(CustomErrorExceptionHandler.java:47)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
...
...

At least I always have the possibility for my DynaView parser to return error page instead of redirecting, and even pass neccessary data for further error handling. That will work 100%.

Pretty is a layer above JSF, so digging down to faces lifecycle internals clashes a bit with Pretty’s ideology :)