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

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

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

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


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

{{ parent.tldr }}

{{ parent.urlSource.name }}