2 Replies Latest reply on Feb 26, 2007 4:38 PM by Bradley Smith

    Seam + jBPM + jBPM-timers

    Bradley Smith Master

      I am having some trouble with jBPM timers and Seam.

      I have a basic jBPM timer stubbed up to call a method in a SLSB - here is the XML that binds the timer to a node:

       <task-node name="User Manager Approve-Reject Request">
      
       <!-- User Manager Escalation Timer -->
       <timer name="Escalate User Manager Approval" duedate="1 minute" repeat="3 minutes">
       <action class="com.evergreen.accesscontrol.jbpmaction.EscalateUserManagerTimer" async="true">
       <customProperty>customValue</customProperty>
       <jndiPathToHandler>access-control-1.0/WorkFlowManagerBean/local</jndiPathToHandler>
       </action>
       </timer>
      
       <task name="Approve/Reject" description="User Manager approve or reject this access request.">
       <assignment actor-id="#{accessRequest.userManagerId}"/>
       </task>
       <transition name="reject" to="end approval request" />
       <transition name="approve" to="User Manager Approved" />
       </task-node>
      


      Here is the impl of the timer action:

      public class EscalateUserManagerTimer implements ActionHandler {
      
       private Log log = LogFactory.getLog(EscalateUserManagerTimer.class);
      
       private String customProperty;
      
       private String jndiPathToHandler;
      
       public void execute(ExecutionContext exeCtx) {
       if (log.isDebugEnabled()) {
       log.info("---------------------> EscalateUserManagerTimer: " + exeCtx);
       log.info("customProperty -> "+customProperty);
       log.info("jndiPathToHandler -> "+jndiPathToHandler);
       }
       try {
       // First - resolve a handle to a WorkFlowManager(Bean)
       InitialContext context = new InitialContext();
       WorkFlowManager workFlowManager = (WorkFlowManager)context.lookup( jndiPathToHandler );
      
       if (workFlowManager == null) {
       log.error("Unable to lookup handler using '"+jndiPathToHandler+"'.");
       } else {
       // Process the task using the work flow manager bean
       Token token = exeCtx.getToken();
       workFlowManager.escalateAccessRequest(token.getId());
      
       }
       } catch (NamingException e) {
       log.error(e,e);
       log.error("TODO - implement some kind of error handling for this ");
       }
       }
      }
      


      and here is the relevant code in workFlowManager:

      
       @In(create = true)
       private JbpmContext jbpmContext;
      
       public void escalateAccessRequest(long tokenId) {
       // TODO : implement me
       log.info("escalateAccessRequest( tokenId="+tokenId+" )");
       }
      
      


      16:03:50,002 DEBUG org.jbpm.JbpmContext - creating JbpmContext
      16:03:50,002 DEBUG org.jbpm.persistence.db.DbPersistenceServiceFactory - creating persistence service
      16:03:50,002 DEBUG org.jbpm.persistence.db.DbPersistenceService - creating hibernate session
      16:03:50,002 DEBUG org.jbpm.scheduler.impl.SchedulerThread - checking for timers
      16:03:50,017 DEBUG org.jbpm.scheduler.impl.SchedulerThread - found timer timer(Escalate User Manager Approval,com.evergreen.accesscontrol.jbpmaction.EscalateUserManagerTimer,16:03:50,000)
      16:03:50,017 DEBUG org.jbpm.scheduler.impl.SchedulerThread - executing timer 'timer(Escalate User Manager Approval,com.evergreen.accesscontrol.jbpmaction.EscalateUserManagerTimer,16:03:50,000)'
      16:03:50,049 DEBUG org.jbpm.scheduler.exe.Timer - executing timer 'timer(Escalate User Manager Approval,com.evergreen.accesscontrol.jbpmaction.EscalateUserManagerTimer,16:03:50,000)'
      16:03:50,064 INFO com.evergreen.accesscontrol.jbpmaction.EscalateUserManagerTimer - ---------------------> EscalateUserManagerTimer: ExecutionContext[Token(/)]
      16:03:50,064 INFO com.evergreen.accesscontrol.jbpmaction.EscalateUserManagerTimer - customProperty -> customValue
      16:03:50,064 INFO com.evergreen.accesscontrol.jbpmaction.EscalateUserManagerTimer - jndiPathToHandler -> access-control-1.0/WorkFlowManagerBean/local
      16:03:50,111 DEBUG org.jbpm.configuration.JbpmContextInfo - creating jbpm context with service factories '[message, scheduler, logging, persistence, authentication]'
      16:03:50,111 DEBUG org.jbpm.JbpmContext - creating JbpmContext
      16:03:50,111 DEBUG org.jbpm.JbpmContext - closing JbpmContext
      16:03:50,111 DEBUG org.jbpm.configuration.JbpmContextInfo - creating jbpm context with service factories '[message, scheduler, logging, persistence, authentication]'
      16:03:50,111 DEBUG org.jbpm.JbpmContext - creating JbpmContext
      16:03:50,111 DEBUG org.jbpm.configuration.JbpmContextInfo - creating jbpm context with service factories '[message, scheduler, logging, persistence, authentication]'
      16:03:50,111 DEBUG org.jbpm.JbpmContext - creating JbpmContext
      16:03:50,111 DEBUG org.jbpm.JbpmContext - closing JbpmContext
      16:03:50,111 DEBUG org.jboss.seam.core.ManagedJbpmContext - created seam managed jBPM context
      16:03:50,111 DEBUG org.jbpm.persistence.db.DbPersistenceServiceFactory - creating persistence service
      16:03:50,111 DEBUG org.jbpm.persistence.db.DbPersistenceService - creating hibernate session
      16:03:50,111 DEBUG org.jboss.mx.loading.RepositoryClassLoader - setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@1cc0d67, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@1df427e{ url=null ,addedOrder=0}
      16:03:50,127 INFO com.evergreen.accesscontrol.impl.WorkFlowManagerBean - escalateAccessRequest( tokenId=42527 )
      16:03:50,158 DEBUG org.jboss.mx.loading.RepositoryClassLoader - setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@1cc0d67, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@16a0d22{ url=null ,addedOrder=0}
      16:03:50,158 DEBUG org.jboss.seam.core.ManagedJbpmContext - destroying seam managed jBPM context
      16:03:50,158 DEBUG org.jbpm.JbpmContext - closing JbpmContext
      16:03:50,158 DEBUG org.jbpm.svc.Services - closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@1843e29
      16:03:50,158 DEBUG org.jbpm.persistence.db.DbPersistenceService - flushing hibernate session
      16:03:50,158 DEBUG org.jbpm.persistence.db.DbPersistenceService - closing hibernate session
      16:03:50,158 DEBUG org.jboss.seam.core.ManagedJbpmContext - done destroying seam managed jBPM context
      16:03:50,158 DEBUG org.jboss.seam.core.ManagedJbpmContext - flushing seam managed jBPM context
      16:03:50,158 WARN org.jbpm.scheduler.exe.Timer - timer action threw exception
      java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:208)
       at org.jbpm.graph.def.Action_$$_javassist_180.execute(Action_$$_javassist_180.java)
       at org.jbpm.scheduler.exe.Timer.execute(Timer.java:84)
       at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:119)
       at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:71)
      Caused by: java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=DEIBKST-6KZFT61/47, BranchQual=, localId=47] status=STATUS_NO_TRANSACTION; - nested throwable: (java.lang.NullPointerException)
       at org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
       at $Proxy430.escalateAccessRequest(Unknown Source)
       at com.evergreen.accesscontrol.jbpmaction.EscalateUserManagerTimer.execute(EscalateUserManagerTimer.java:61)
       at org.jbpm.graph.def.Action.execute(Action.java:123)
       ... 9 more
      Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=DEIBKST-6KZFT61/47, BranchQual=, localId=47] status=STATUS_NO_TRANSACTION; - nested throwable: (java.lang.NullPointerException)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
       at org.jboss.tm.TxManager.commit(TxManager.java:240)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
       ... 27 more
      Caused by: java.lang.NullPointerException
       at org.jboss.seam.core.ManagedJbpmContext.beforeCompletion(ManagedJbpmContext.java:94)
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
       ... 29 more
      16:03:50,205 ERROR org.jbpm.scheduler.exe.Timer - unhandled timer exception
      java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:208)
       at org.jbpm.graph.node.TaskNode_$$_javassist_135.raiseException(TaskNode_$$_javassist_135.java)
       at org.jbpm.scheduler.exe.Timer.execute(Timer.java:94)
       at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:119)
       at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:71)
      Caused by: java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:208)
       at org.jbpm.graph.def.ProcessDefinition_$$_javassist_138.raiseException(ProcessDefinition_$$_javassist_138.java)
       at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:346)
       ... 9 more
      Caused by: org.jbpm.graph.def.DelegationException
       at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:352)
       ... 16 more
      Caused by: java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:208)
       at org.jbpm.graph.def.Action_$$_javassist_180.execute(Action_$$_javassist_180.java)
       at org.jbpm.scheduler.exe.Timer.execute(Timer.java:84)
       ... 2 more
      Caused by: java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=DEIBKST-6KZFT61/47, BranchQual=, localId=47] status=STATUS_NO_TRANSACTION; - nested throwable: (java.lang.NullPointerException)
       at org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
       at $Proxy430.escalateAccessRequest(Unknown Source)
       at com.evergreen.accesscontrol.jbpmaction.EscalateUserManagerTimer.execute(EscalateUserManagerTimer.java:61)
       at org.jbpm.graph.def.Action.execute(Action.java:123)
       ... 9 more
      Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=DEIBKST-6KZFT61/47, BranchQual=, localId=47] status=STATUS_NO_TRANSACTION; - nested throwable: (java.lang.NullPointerException)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
       at org.jboss.tm.TxManager.commit(TxManager.java:240)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
       ... 27 more
      Caused by: java.lang.NullPointerException
       at org.jboss.seam.core.ManagedJbpmContext.beforeCompletion(ManagedJbpmContext.java:94)
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
       ... 29 more
      
      


      It looks to me like several jBPM contexts get created in the execution of this timer. And I can imagine that when jBPM 'wakes' up for execution of the task, it's not necessarily doing so with all the context that Seam components have...

      Does anyone have knowledge or practice using jBPM timers that call SLSB's that are Seam components?

      Thanks,
      Brad Smith