Hello All,I am trying to set up persistence for a standalone Drools (6.0.1.Final) application that uses JPA, Hibernate (4.3.5.Final) and Bitronix (2.1.4) via Spring (4.0.3.RELEASE).On the persistence side everything appears to be set up correctly. For my Drools session I use a KieContainer to create a new stateful session using an environment set up with the EntityManagerFactory and TransactionManager set. The problem that I am experiencing however is that nothing is getting persisted to the database. I have poured over the docs at least two dozen times and searched the net for anything related.Here is what my Spring context file looks like when creating the Drools session...<bean id="kReleaseId" factory-bean="kieServices" factory-method="newReleaseId"><constructor-arg index="0" value="groupId"/><constructor-arg index="1" value="artifactId"/><constructor-arg index="2" value="1.0-SNAPSHOT"/></bean><bean id="kContainer" factory-bean="kieServices" factory-method="newKieContainer"><constructor-arg index="0" ref="kReleaseId"/></bean><bean id="kEnvironment" factory-bean="kieServices" factory-method="newEnvironment"><constructor-arg index="0"><map><entry><key><util:constant static-field="org.kie.api.runtime.EnvironmentName.ENTITY_MANAGER_FACTORY"/></key><ref bean="entityManagerFactory"/></entry><entry><key><util:constant static-field="org.kie.api.runtime.EnvironmentName.TRANSACTION_MANAGER"/></key><ref bean="jtaTransactionManager"/></entry></map></constructor-arg></bean><bean id="kSession" factory-bean="kContainer" factory-method="newKieSession"><constructor-arg index="0" ref="kEnvironment"/></bean>Since the application is standalone I execute fireAllRules on the session at a regular interval (I use this instead of fireUntilHalt as it dramatically reduces the CPU load on the machine). With each call I wrap it in a transaction. Thus, the code looks as follows:while (!Thread.currentThread().isInterrupted()) {// Start a new transactionUserTransaction utx = utx = (UserTransaction)new InitialContext().lookup("java:comp/UserTransaction");utx.begin();// Tick the sessionkSession.fireAllRules();// Close the transactionutx.commit();// Sleep so that other applications can use the CPUtry {Thread.sleep(1);} catch (InterruptedException e) {// When our sleep is interrupted it's because the executor wants us to shut down.Thread.currentThread().interrupt();}}When I inspect kSession in the debugger I can see the environment is properly set. I have tried digging down into the execute a bit but can't find any point at which the TransactionManager or EntityManagerFactory are used. As I said above I know Hibernate is set up correctly as well as Bitronix. I can see them working just fine in the logs and they definitely are hitting the database (and create tables for sessioninfo and workingmemory as they should). I just get nothing actually in the database stored, ever.Any help here is appreciated. It seems like it should work but it just doesn't.Thanks in advance,Jean-Philippe Steinmetz
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users