5

I am getting below exception whenever I switch one state to another more then 15 times in web-flow.

No flow execution snapshot could be found with id '1'; perhaps the snapshot has been removed? . Stacktrace follows:
org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key 'e7s1'
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.webflow.execution.repository.snapshot.SnapshotNotFoundException: No flow execution snapshot could be found with id '1'; perhaps the snapshot has been removed? 
... 3 more

I am using grails webflow plug-in.

Are anyone have any idea why this is occurring and how to resolve this?

Neeraj Bhatt
  • 145
  • 2
  • 13

3 Answers3

8

Web Flow only retains a specified number of Executions ("e7") and Snapshots ("s1") in its repository at one time. This is useful in order to limit how much memory can be consumed. I'm guessing the default is 15, in which case Execution "e7" can have 15 Snapshots as you move from state to state. Once you've hit "e7s16", "s1" will be discarded, thus giving you the result you see.

You can change the defaults with the <webflow:flow-execution-repository> configuration element:

<!-- Executes flows: the entry point into the Spring Web Flow system -->
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
    <webflow:flow-execution-repository max-execution-snapshots="20" max-executions="2"/>
</webflow:flow-executor>

Quoting that link above:

Tune the max-execution-snapshots attribute to place a cap on the number of history snapshots that can be taken per flow execution. To disable snapshotting, set this value to 0. To enable an unlimited number of snapshots, set this value to -1.

I do find the default behavior unacceptable, though, when you happen to visit an expired Snapshot and you just get an Exception. Another recent question asked about how to catch that case, presumably so you can do something more useful when it occurs.

(We implemented custom code to carry along in the HttpSession the last valid Snapshot so that we could send the user there when that exception occurs.)

Community
  • 1
  • 1
dbreaux
  • 4,982
  • 1
  • 25
  • 64
  • 1
    Default, if not specified in flow-execution-repository configuration, max-execution-snapshots is 30 and max-executions is 5. We can get this from name=flowExecutionRepositoryType in: http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd – Prasad Jun 19 '14 at 20:51
1

Thanks for yours helps. But I am using grails application. I had fixed it using the following code.

DefaultFlowExecutionRepository defaultFlowExecutionRepository=(DefaultFlowExecutionRepository)Holders.applicationContext.getBean('flowExecutionRepository');
defaultFlowExecutionRepository.setMaxSnapshots(100)
Neeraj Bhatt
  • 145
  • 2
  • 13
  • 4
    Well, that doesn't "fix" it, it just increases the number of snapshots allowed until you get the same error. – dbreaux Jul 07 '14 at 16:21
0

For newer versions of SpringWebflow, as seen here:

https://docs.spring.io/spring-webflow/docs/2.4.4.RELEASE/reference/html/system-setup.html#tuning-flow-execution-repository

You can simple write this on your java configuration code:

@Bean
public FlowExecutor flowExecutor() {
    return getFlowExecutorBuilder(flowRegistry())
            .setMaxFlowExecutions(5)
            .setMaxFlowExecutionSnapshots(30)
            .build();
}

If you want to keep infinite values of Snapshot versions, just set the, maxFlorExecutionSnapshots to -1.

Henrique
  • 11
  • 4