1


I am not sure either I missed a point in the concept of exception handling in webflow, or this is a bug.
I hope someone can help me to understand it, or I will file a bug in webflow/spring mvc.
Following situation.
JSF2 (2.1.X) with webflow 2.4.0 and spring faces (2.4.0)
A RuntimeException is thrown during render phase. Not nice, but can happen.
Exceptionhandling kicks in, a it tries a make a new tansition to an error site. Works like expected.
ErrorState is resolved, it tries to make a transition to it.
Everything is ok so far.
Now here is the problem. The transition will never be executed.
org.springframework.webflow.engine.ViewState

protected void doEnter(RequestControlContext context) throws FlowExecutionException {
        context.assignFlowExecutionKey();
        ExternalContext externalContext = context.getExternalContext();
        if (externalContext.isResponseComplete()) {
            if (!externalContext.isResponseCompleteFlowExecutionRedirect()) {
                clearFlash(context);
            }
        } else {
            if (shouldRedirect(context)) {
                context.getExternalContext().requestFlowExecutionRedirect();
                if (popup) {
                    context.getExternalContext().requestRedirectInPopup();
                }
            } else {
                View view = viewFactory.getView(context);
                context.setCurrentView(view);
                render(context, view);
            }
        }
    }

Transition will only be done if the response is not already completed.
This will never happen for any exception in the render phase, because in org.springframework.faces.mvc.JsfView in the finally block there will be always a responseComplete.

/**
 * Performs the standard duties of the JSF RENDER_RESPONSE phase.
 */
public void render() throws IOException {
    FacesContext facesContext = FlowFacesContext.getCurrentInstance();
    if (facesContext.getResponseComplete()) {
        return;
    }
    facesContext.setViewRoot(this.viewRoot);
    try {
        logger.debug("Asking faces lifecycle to render");
        this.facesLifecycle.render(facesContext);
    } finally {
        logger.debug("View rendering complete");
        facesContext.responseComplete();
    }
}

For me it looks like a bug. How is the webflow exceptionhandling to work with exceptions in the renderphase?

There is no way to change the responseComplete-Flag, in org.springframework.webflow.context.servlet.ServletExternalContext
It is a private field with only the possibility to set it to true via

public void recordResponseComplete() {
    responseComplete = true;
}

I changed in the debugger-session the flag to false.
Then everything works like expected, and the user sees can see the error page.

  • please read http://stackoverflow.com/questions/18744910/using-jsf-as-view-technology-of-spring-mvc and reconsider your 'architecture' or does the combination actually work for you (not using jsf components just facelets)? – Kukeltje Jun 05 '15 at 10:52
  • This is not an architecture problem. The combination worked for years, we just migrated to jsf2, with a new webflow version. It just feels strange that no one has seen this error before. It was working in jsf 1.2 But because the whole exception handling is in webflow and spring-faces, The question is, how are other people handling this situation, or is this a real bug. The code in webflow 2.4 changed dramatically, so it is hard to analyze where it was introduced. – Andreas Zschorn Jun 05 '15 at 11:11
  • Looks like a bug. I recommend you open one. They finally started to work on them and will be releasing 2.4.2 soon. Maybe they can squeeze yours in.https://jira.spring.io/browse/SWF – Selwyn Jun 05 '15 at 17:52
  • @Kukeltje: Spring WF != Spring MVC (SWF is roughly what JSF 2.2 `@FlowScoped` does). – BalusC Jun 06 '15 at 07:58

0 Answers0