Adding deeper logging to Webflow Exceptions

DZone 's Guide to

Adding deeper logging to Webflow Exceptions

· Java Zone ·
Free Resource

If you've been using Roo and the JSPX views with WebFlow, you've probably noticed that you don't get the embedded stack trace in the errors that result.  You can fix this with a lifecycle listener:

First, define the class:

package mypackage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.webflow.execution.FlowExecutionException;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.RequestContext;

public class LoggingFlowExecutionListener extends FlowExecutionListenerAdapter {
Logger logger = LoggerFactory.getLogger(
public void exceptionThrown(RequestContext context,
FlowExecutionException exception) {
super.exceptionThrown(context, exception);
logger.error("Webflow " + context.getActiveFlow().getId() +
" threw exception in " + context.getCurrentState().getId(), exception);

Then, in webflow-config.xml, replace

<webflow:flow-executor id="flowExecutor" />


<webflow:flow-executor id="flowExecutor">
<webflow:listener ref="loggingListener"/>

<bean class="mypackage.LoggingFlowExecutionListener" id="loggingListener" />

Now you can enjoy useful logging from your Webflow exceptions.

From http://www.rimple.com/tech/2011/2/28/adding-deeper-logging-to-webflow-exceptions.html


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}