|
|
Problem with object in flow scope with shared controller Action
Hi, in our project we use Spring WebFlow 2.0.6. We have a flow which is rendered by MyAction. Using lt;on-startgt; of the flow we call a method myMethod() in MyAction and put result in flow scope.
There are two application pages that both access MyAction and myMethod(), one is A and another is B. In both these cases myMethod() puts some user data in a form which is set to flow scope as above.
Our qa caught a defect that a user on page A sees form data of a different user on page B, although not always. This happens sometimes if the user in page A reaches there almost around the time the user in page B reaches.
We have multiple managed Weblogic servers and we compared the JSessionIDs to be different of both these users and requests coming from different IP addresses as well.
Following are the flow definitions:
lt;var name=quot;myFormquot; class=quot;com.abc.MyFormBeanquot; /gt;
lt;on-startgt;
lt;evaluate expression=quot;myAction.myMethod(flowRequestContext)quot;
result=quot;flowScope.myFormquot; /gt;
lt;/on-startgt;
lt;action-state id=quot;myActionquot;gt;
lt;evaluate expression=quot;myActionquot; /gt;
lt;transition on=quot;notLoggedInquot; to=quot;askLoginquot; /gt;
lt;/action-stategt;
We put loggers in MyAction class to see if only a single instance was being shared across all flows and on both pages A and B - this we found to be true. WebFlow created only one instance of PaymentAction and shared it across all pages and flows.
Also, we noticed that similar logger on the MyForm inside myMethod() created a different instance everytime because we are creating a new object over there every time before returning from myMethod() to be put into flow scope.
This is a very important issue we need to resolve asap and request any help soon as possible.
Thank you,
What is the scope of your beans?
Do you use default? If so, try to set the scope of your beans to session or request using the quot;@Scopequot; annotation.
The problem was elsewhere in the code - we were using an instance variable on the Action which was a singleton scoped bean.
Thanks to all those who took the time and cared to reply! |
|