Over a million developers have joined DZone.

Adding deeper logging to Webflow Exceptions

DZone's Guide to

Adding deeper logging to Webflow Exceptions

· Java Zone ·
Free Resource

The CMS developers love. Open Source, API-first and Enterprise-grade. Try BloomReach CMS for free.

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

BloomReach CMS: the API-first CMS of the future. Open-source & enterprise-grade. - As a Java developer, you will feel at home using Maven builds and your favorite IDE (e.g. Eclipse or IntelliJ) and continuous integration server (e.g. Jenkins). Manage your Java objects using Spring Framework, write your templates in JSP or Freemarker. Try for free.


Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}