[rules-users] ksession.dispose() and DroolsSpringJpaManager.dispose()

drooRam rajeshram7 at yahoo.com
Mon Sep 20 16:59:45 EDT 2010


I have question on kession.dispose(), what is the best place to call this
method?

I have a code where in i call

   ksession.startProcess("someprocess", mapParam);
   ksession.fireAllRules();
   ....
   finally{
       ksession.dispose(); 
    }

If i invoke the kession.dispose() like the above, I always ended up in "No
value bound to the key" - Transaction exception.

My understanding is that all the calls to drools should be enclosed in a
transactional unit. I have done that so. 

My observation is that DroolsSpringJpaManager.dispose() method is being
invoked due to my call to ksession.dispose() after the transaction has begun
from my app code and right before the  transaction.aftercompletioncommit()
call.

I can see a line of code in DroolsJpaManager.dispose() method,

   TransactionSynchronizationManager.unbindResource(this.emf) //
entityManagerFactory reference borrowed from application code.

My question is that why the above line of code is necessary in dispose()
method since this.emf is the reference obtained from Application code jpa
manager, since this method unbinded this resource, transaction initiated
from the application code is also trying to unbind the same resource once
everything is completed results to "No value found for this key exception".


When i comment out ksession.dispose() call from my app code, it works fine.
At this point, i am not sure when to invoke ksession.dispose() call and why 
the TransactionSynchronizationManager.unbindResource(this.emf)  being made
in DroolsSpringJpaManager.dispose() on a reference obtained from
JpaTransactionManager ?

-drooRam
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/ksession-dispose-and-DroolsSpringJpaManager-dispose-tp1531549p1531549.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list