umberto maguolo [
https://community.jboss.org/people/umb71] created the discussion
"timer job issues when disposing session in embedded j2ee process"
To view the discussion, visit:
https://community.jboss.org/message/824721#824721
--------------------------------------------------------------
Hi all,
i'm using jBPM 5.4, I have a knowledge session with a process instance in it,
embebbed in an ejb with container managed transaction, the process definition has a timer
intermediate event in it:
i'm using jpa persistence but the problem arises also with in memory session without
persistence. I've utilized the CMTDisposeCommand class to register the synchronization
with the transaction manager and implemented the afterCompletion method to be notified
when the container finishes it's work committing the transaction; in the
afterCompletion method i've utilized the DefaultProcessEventListener and implemented
the afterProcessCompleted method so i can (at least i thought it was so) dispose my
knowledge session at the end of all the process elaboration.
The problem is that the process is regularly terminated but it seams that the timer
service sheduler is not aware of that fact neither that the session is disposed and it
continuosly try to signal the timer event on the session. When i call the
ksession.dispose, in the afterProcessCompleted method, i get the exception in the server
console:
SEVERE: Error when executing timer job
java.lang.IllegalStateException: Illegal method call. This session was previously
disposed.
at
org.drools.reteoo.DisposedReteooWorkingMemory.getLastIdleTimestamp(DisposedReteooWorkingMemory.java:562)
at
org.drools.impl.StatefulKnowledgeSessionImpl.getLastIdleTimestamp(StatefulKnowledgeSessionImpl.java:890)
at
org.drools.persistence.SingleSessionCommandService$EndOperationListenerImpl.endOperation(SingleSessionCommandService.java:334)
at
org.drools.common.AbstractWorkingMemory.endOperation(AbstractWorkingMemory.java:1365)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1006)
at
org.drools.impl.StatefulKnowledgeSessionImpl.executeQueuedActions(StatefulKnowledgeSessionImpl.java:866)
at
org.jbpm.process.instance.event.DefaultSignalManager.signalEvent(DefaultSignalManager.java:90)
at
org.jbpm.process.instance.timer.TimerManager$ProcessJob.execute(TimerManager.java:323)
at org.drools.time.SelfRemovalJob.execute(SelfRemovalJob.java:15)
at
org.drools.time.impl.DefaultTimerJobInstance.call(DefaultTimerJobInstance.java:51)
at
org.drools.persistence.jpa.JpaTimerJobInstance.internalCall(JpaTimerJobInstance.java:43)
at
org.drools.persistence.jpa.JDKCallableJobCommand.execute(JDKCallableJobCommand.java:20)
at
org.drools.persistence.jpa.JDKCallableJobCommand.execute(JDKCallableJobCommand.java:6)
at
org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)
at
org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:373)
at
org.drools.persistence.jpa.JpaTimerJobInstance.call(JpaTimerJobInstance.java:34)
at
org.drools.persistence.jpa.JpaTimerJobInstance.call(JpaTimerJobInstance.java:14)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
giu 25, 2013 11:46:41 AM org.drools.time.impl.DefaultTimerJobInstance call
WARNING: Unable to execute timer job!
java.lang.IllegalStateException: Illegal method call. This session was previously
disposed.
at
org.drools.reteoo.DisposedReteooWorkingMemory.getProcessInstance(DisposedReteooWorkingMemory.java:382)
at
org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:297)
at
org.jbpm.process.instance.timer.TimerManager$ProcessJob.execute(TimerManager.java:335)
at org.drools.time.SelfRemovalJob.execute(SelfRemovalJob.java:15)
at
org.drools.time.impl.DefaultTimerJobInstance.call(DefaultTimerJobInstance.java:51)
at
org.drools.persistence.jpa.JpaTimerJobInstance.internalCall(JpaTimerJobInstance.java:43)
at
org.drools.persistence.jpa.JDKCallableJobCommand.execute(JDKCallableJobCommand.java:20)
at
org.drools.persistence.jpa.JDKCallableJobCommand.execute(JDKCallableJobCommand.java:6)
at
org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)
at
org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:373)
at
org.drools.persistence.jpa.JpaTimerJobInstance.call(JpaTimerJobInstance.java:34)
at
org.drools.persistence.jpa.JpaTimerJobInstance.call(JpaTimerJobInstance.java:14)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
I've also tried to cancel any TimerJobInstance in the TimerService prior to dispose
the session but the problem is still present. Am i doing something wrong? Missing
something? What is the correct way of disposing session with (terminated) timer events in
it?
Thanks.
Umberto
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/824721#824721]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]