JBoss Community

Drools - unable to commit after fireRules with retract

created by Carlo Carrara in jBPM - View the full discussion

I’m using drools 5.4.0.Final & JPA on JBossAS 7.1.1 and MySQL 5 with attached rules file.

All things go fine if I add facts in entry points "startVM" or "destroyVM" (related rules has “retract” instruction commented), but things go wrong when I add facts in entry points "createVM" or "stopVM" (related rules has “retract” instruction active).

 

The events sequence is this:

  1. Startup application with clean db
  2. Execute fireRules
  3. Add some facts in entry points "startVM" or "destroyVM" (related rules has “retract” instruction commented)
  4. Execute fireRules
  5. Stop application
  6. Restart application, reloading some facts from db
  7. Add a fact in entry point "createVM" or "stopVM" (related rules has “retract” instruction active)
  8. Execute fireRules
  9. Stop application
  10. Restart application, reloading some facts from db
  11. Execute fireRules: error thrown!

I can do anything before step 7 in any combination, and everything goes fine. The problem is created by step 7.

Here the exception  thrown:

Every “add a fact” step and “execute fireRules” step is under transaction.

 

2012-05-21 19:46:06.441 | fireRules1 |  |  |  | ERROR | com.abc.eventprocessor.rule.drools.DroolsRuleEngine | fireRules | error firing rules

        javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.

        at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1177) ~[na:na]

        at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:117) ~[na:na]

        at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75) ~[na:na]

        at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:167) ~[na:na]

        at com.abc.eventprocessor.rule.drools.DroolsRuleEngine.fireRules(DroolsRuleEngine.java:169) ~[classes:1.0.0-SNAPSHOT]

        at com.abc.eventprocessor.scheduler.FireRulesJobDetail.executeInternal(FireRulesJobDetail.java:35) [classes:1.0.0-SNAPSHOT]

        at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113) [spring-context-support-3.1.1.RELEASE.jar:3.1.1.RELEASE]

        at com.abc.commons.quartz.ClusterizableJobMap.executeInternal(ClusterizableJobMap.java:28) [commons-1.0.3-SNAPSHOT.jar:1.0.3-SNAPSHOT]

        at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113) [spring-context-support-3.1.1.RELEASE.jar:3.1.1.RELEASE]

        at org.quartz.core.JobRunShell.run(JobRunShell.java:216) [quartz-1.8.4.jar:na]

        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) [quartz-1.8.4.jar:na]

Caused by: javax.persistence.PersistenceException: error during managed flush

        at org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1486) ~[hibernate-entitymanager-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76) ~[na:na]

        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273) ~[na:na]

        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93) ~[na:na]

        at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:164) ~[na:na]

        at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165) ~[na:na]

        ... 10 common frames omitted

Caused by: java.lang.NullPointerException: null

        at org.drools.reteoo.ObjectTypeNode$ExpireJobContextTimerOutputMarshaller.serialize(ObjectTypeNode.java:668) ~[drools-core-5.4.0.Final.jar:5.4.0.Final]

        at org.drools.marshalling.impl.ProtobufOutputMarshaller.writeTimers(ProtobufOutputMarshaller.java:691) ~[drools-core-5.4.0.Final.jar:5.4.0.Final]

        at org.drools.marshalling.impl.ProtobufOutputMarshaller.serializeSession(ProtobufOutputMarshaller.java:176) ~[drools-core-5.4.0.Final.jar:5.4.0.Final]

        at org.drools.marshalling.impl.ProtobufOutputMarshaller.writeSession(ProtobufOutputMarshaller.java:100) ~[drools-core-5.4.0.Final.jar:5.4.0.Final]

        at org.drools.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:169) ~[drools-core-5.4.0.Final.jar:5.4.0.Final]

        at org.drools.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:151) ~[drools-core-5.4.0.Final.jar:5.4.0.Final]

        at org.drools.persistence.SessionMarshallingHelper.getSnapshot(SessionMarshallingHelper.java:72) ~[drools-persistence-jpa-5.4.0.Final.jar:5.4.0.Final]

        at org.drools.persistence.info.SessionInfo.update(SessionInfo.java:85) ~[drools-persistence-jpa-5.4.0.Final.jar:5.4.0.Final]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0]

        at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0]

        at org.hibernate.ejb.event.BeanCallback.invoke(BeanCallback.java:39) ~[hibernate-entitymanager-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:110) ~[hibernate-entitymanager-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.ejb.event.EntityCallbackHandler.preUpdate(EntityCallbackHandler.java:95) ~[hibernate-entitymanager-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.ejb.event.EJB3FlushEntityEventListener.invokeInterceptor(EJB3FlushEntityEventListener.java:65) ~[hibernate-entitymanager-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.event.internal.DefaultFlushEntityEventListener.handleInterception(DefaultFlushEntityEventListener.java:315) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.event.internal.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:266) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:149) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:225) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1081) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:315) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:104) ~[hibernate-core-4.0.1.Final.jar!/:4.0.1.Final]

        ... 16 common frames omitted

 

After this error I need to clean the db and loose session data.

 

How can I get out of this problem?

Reply to this message by going to Community

Start a new discussion in jBPM at Community