How to: Spring Webflow 2 and Spring Security 3

There have been recent discussions in the Spring Framework group to make Spring Security 3 working with Spring Webflow 2. Enabling it is quite easy when working with Maven, however due to refactoring not all Spring Webflow classes are working (or actually resulting in a ClassNotFoundException).

Add dependency of Spring Webflow and Spring Security with Maven

And the following dependencies (in addition to the spring framework dependencies or whatever you require):

Setup Spring Security

Setup Spring Security as you would set it up usually. For example start with something like this:

Webflow setup and custom class

Your webflow setup might be similar to the following:

And exactly this securityFlowExecutionListener is the problem, as it will run into a runtime error due to classes that could not be found. So the solution for that is quite simple. First define the securityFlowExecutionListener as a reference to a custom bean:

The easiest is to copy the class and adjust it accordingly so it compiles. For example, take the version from the Spring Jira Issue.