Abort further processing of a Faces Request?

From: Lincoln Baxter, III <>
Date: Sun, 3 Jan 2010 15:57:43 -0500

I'm trying to do a servlet forward in a PhaseListener, via
ExternalContext.dispatch(), before RESTORE_VIEW phase.

What happens, though, is that the lifecycle continues in the current
thread, even though the request has been dispatched. It seems like
dispatch() should do some kind of internal abort to tell Faces to stop
processing. Or... faces should check to see if the request has been
dispatched immediately before attempting the next phase.

Assuming that there is no viewId specified, The result of this is an
Explosion when faces attempts to create a UIViewRoot that doesn't
exist, when instead, I feel the request should already have been
aborted and no view should be created, even if there were to be a
viewId defined.

The forwarded thread completes successfully and the new page displays.

Is this a bug, a spec enhancement, or user error?

Caused by: java.lang.NullPointerException
        at javax.faces.component.UIViewRoot.setLocale(
        at com.sun.faces.application.view.ViewHandlingStrategy.createView(
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.createView(
        at com.sun.faces.application.view.MultiViewHandler.createView(
        at com.ocpsoft.pretty.application.PrettyViewHandler.createView(
        at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(
        at com.sun.faces.lifecycle.RestoreViewPhase.execute(
        at com.sun.faces.lifecycle.Phase.doPhase(
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(
        at com.sun.faces.lifecycle.LifecycleImpl.execute(
        at javax.faces.webapp.FacesServlet.service(
        ... 86 more

Lincoln Baxter, III
"Keep it Simple"