JBoss Community

Re: Drools, Spring integration and JTA in container

created by Fabio Wang in jBPM - View the full discussion

Hi there,

 

After some time struggling to make this "Spring + JTA + Drools" integration, I could make it work, but I'm still unsure if it's the right way. As everyone pointed out, the SingleSessionComand#initTransactionManager ignores the case where a org.springframework.transaction.jta.JtaTransactionManager is used. So I had to manually create an Environment like this:

 

Environment environment = EnvironmentFactory.newEnvironment();

environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

DroolsSpringTransactionManager jtaTransactionManager = new DroolsSpringTransactionManager(ptm);

this.environment.set(EnvironmentName.TRANSACTION_MANAGER, jtaTransactionManager);

DroolsSpringJpaManager pcm = new DroolsSpringJpaManager(environment);

environment.set(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, pcm);

 

 

And, after that, I create my ksession (unfortunately, without the <drools:ksession/> shortcut):

 

ksession = JPAKnowledgeService.newStatefulKnowledgeSession(this.kbase, null, environment);

 

 

Hope this helps.

Fábio

Reply to this message by going to Community

Start a new discussion in jBPM at Community