View Full Version : jBPM and Spring transactions
wrschneider99
Jun 5th, 2006, 01:45 PM
I've been trying to get jBPM to work with Spring-managed transactions. I posted a detailed reply to message that's probably not in the right forum, since this is specifically an issue with jBPM integration rather than the core DAO/TX stuff:
http://forum.springframework.org/showthread.php?t=25253&page=2
Summary is, jBPM isn't honoring declarative transactions because it calls SessionFactory.openSession directly. Even if it has the right SessionFactory, openSession starts a *new* session/connection.
Any help or insight would be greatly appreciated.
Thanks,
Bill
wrschneider99
Jun 5th, 2006, 06:43 PM
I've been trying to get jBPM to work with Spring-managed transactions. I posted a detailed reply to message that's probably not in the right forum, since this is specifically an issue with jBPM integration rather than the core DAO/TX stuff:
http://forum.springframework.org/showthread.php?t=25253&page=2
Summary is, jBPM isn't honoring declarative transactions because it calls SessionFactory.openSession directly. Even if it has the right SessionFactory, openSession starts a *new* session/connection.
Any help or insight would be greatly appreciated.
Thanks,
Bill
Update: I found a workaround, but I'm not happy with it.
I switched from HibernateTransactionManager to DataSourceTransactionManager, so the underlying java.sql.Connection will be the same even if the Session isn't.
(web log entry: http://jroller.com/page/bschneider?entry=jbpm_and_spring_transaction_manag ement)
IMO this is a shortcoming in jBPM. It should be able to use SessionFactory.getCurrentSession, which would use the current request-scoped or transaction-scoped Session.
-- Bill
Costin Leau
Jun 6th, 2006, 01:25 AM
I haven't looked at 3.1.1 yet but in general, jBPM makes heavy uses of static methods and variables and it's pretty hard to override it. If you look at the code inside Spring Modules jbpm you'll see that is goes to great length to integrate it with jBPM and it doesn't always successes.
You can raise an issue on JIRA and I will take a look at it (though not in the very near future) and maybe I will find a workaround.
Thanks for pointing out the problem.
wrschneider99
Jun 6th, 2006, 07:40 AM
I haven't looked at 3.1.1 yet but in general, jBPM makes heavy uses of static methods and variables and it's pretty hard to override it. If you look at the code inside Spring Modules jbpm you'll see that is goes to great length to integrate it with jBPM and it doesn't always successes.
You can raise an issue on JIRA and I will take a look at it (though not in the very near future) and maybe I will find a workaround.
Thanks for pointing out the problem.
found this on jBPM JIRA; supposedly marked CLOSED but not sure how to use it.
http://jira.jboss.com/jira/browse/JBPM-297
wrschneider99
Jun 6th, 2006, 12:54 PM
I haven't looked at 3.1.1 yet but in general, jBPM makes heavy uses of static methods and variables and it's pretty hard to override it. If you look at the code inside Spring Modules jbpm you'll see that is goes to great length to integrate it with jBPM and it doesn't always successes.
You can raise an issue on JIRA and I will take a look at it (though not in the very near future) and maybe I will find a workaround.
Thanks for pointing out the problem.
Finally figured it out.
The issue was that I had to pass a HibernateTemplate to JbpmTemplate, so it can inject the Session itself (not SessionFactory!) into JbpmContext.
This was non-obvious--I figured that since I had already injected the SessionFactory, that would be it. I should open a JIRA issue to suggest improvement.
--Bill
Costin Leau
Jun 6th, 2006, 04:07 PM
Thanks for reporting, I'll try to address the issue before the 0.4 release.
Costin Leau
Jun 10th, 2006, 02:32 PM
Spring Modules 0.4 was just released and the jBPM module uses the context sessionFactory if it's available. See https://springmodules.dev.java.net/
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.