Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web flow Exception: No flow execution snapshot could be found with id '1'

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?

like image 427
Neeraj Bhatt Avatar asked Jan 11 '23 09:01

Neeraj Bhatt


1 Answers

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.)

like image 100
dbreaux Avatar answered May 07 '23 23:05

dbreaux