PDA

View Full Version : How to implement PersistenceContext in SWF 2 RC1



ivan2007
Apr 14th, 2008, 04:49 PM
Hi,

I am trying to use a persistence context in both a parent and subflow.
When entering the subflow I get the following:



java.lang.IllegalStateException: Already value [org.springframework.orm.hibernate3.SessionHolder@1 254e59] for key [org.hibernate.impl.SessionFactoryImpl@56b64c] bound to thread [http-8084-4]
org.springframework.transaction.support.Transactio nSynchronizationManager.bindResource(TransactionSy nchronizationManager.java:169)
org.springframework.webflow.persistence.HibernateF lowExecutionListener.bind(HibernateFlowExecutionLi stener.java:173)
org.springframework.webflow.persistence.HibernateF lowExecutionListener.sessionStarting(HibernateFlow ExecutionListener.java:110)
org.springframework.webflow.engine.impl.FlowExecut ionListeners.fireSessionStarting(FlowExecutionList eners.java:117)
org.springframework.webflow.engine.impl.FlowExecut ionImpl.start(FlowExecutionImpl.java:359)
org.springframework.webflow.engine.impl.RequestCon trolContextImpl.start(RequestControlContextImpl.ja va:229)
org.springframework.webflow.engine.SubflowState.do Enter(SubflowState.java:101)
org.springframework.webflow.engine.State.enter(Sta te.java:193)
org.springframework.webflow.engine.Transition.exec ute(Transition.java:222)


I guess that webflow is trying to bind a persistence context while there is already one available. I am having this problem for longer than a month and still haven't found a solution.
According to the ref guide there is also a ConversationScoped PersistenceContext pattern. I think this should make the the persistence context available for subflows.
The ref guide however doesn't tell me how this is implemented.
Any suggestions?

Keith Donald
Apr 14th, 2008, 04:57 PM
Hi Ivan,

This appears to be a bug in the persistence listener when working with subflows (HibernateFlowExecutionListener in this case). When the subflow is started the suspending parent should take care to unbind the session, but this is not being done. Can you create a JIRA? We'll fix this promptly and you can grab the fix in a nightly build.

Thanks

Keith

Keith Donald
Apr 20th, 2008, 12:34 AM
This issue has been resolved in http://jira.springframework.org/browse/SWF-600.

If you can confirm in the next nightly build this resolution works for you in your environment that would be great!

ivan2007
Apr 21st, 2008, 10:09 AM
Thanks Keith,

I confirm that it finally works now. Great Job!!