1 Reply Latest reply on Aug 19, 2008 9:06 AM by Peter Brewer

    Calling processInstance.end() when the the process is waitin

    Peter Brewer Novice

      I'm using Jboss Seam 2.0.1.GA with jbpm 3.2.3.GA.

      I have a simple process that has a process-state in it. Sometimes, I need to cancel the parent process instance, which should also cancel the child (process-state) process instance, if the child happens to be open.

      Once the child process is in the wait state if I find the parent process instance and call the end() method then I get an error.

      The error is complaining that the getVariable method is returning null, which is fair enough as presumably its just been cancelled. But why that code even being evaluated?

      To me the process appears to be continuing execution instead of ending it immediately. Is this the correct behaviour or am I doing something unexpected? Any help with this would be much appreciated. Full details below.

      Thanks in advance,
      Pete.

      Code used to cancel the parent process

       public void cancel() {
       Query query = getJbpmContext().getSession().getNamedQuery("processInstanceId.findByNameUnended") ;
       query.setParameter("name", "parentCancel") ;
      
       for (Long pid : (List<Long>)query.list()) {
       log.info("Ending process #0", pid) ;
       ProcessInstance processInstance = getJbpmContext().getProcessInstanceForUpdate(pid) ;
       processInstance.end() ;
       }
      
      
       }
      


      Here are the definitions:
      parent:
      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition xmlns="urn:jbpm.org:jpdl-3.2"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/xsd/jpdl-3.2.xsd"
       name="parentCancel" >
      
       <start-state name="start">
       <transition to="waitForSomething"></transition>
       </start-state>
      
       <process-state name="waitForSomething">
       <sub-process name="childCancel"/>
       <variable name="waitForSomethingOutcome" access="write" mapped-name="outcome" />
       <transition to="checkOutcome"></transition>
       </process-state>
      
       <decision name="checkOutcome" expression="#{processStateCancelTest.getVariable('waitForSomethingOutcome')}">
       <transition to="success" name="successOutcome"></transition>
       <transition to="fail" name="failOutcome"></transition>
       </decision>
       <end-state name="fail">
       </end-state>
       <end-state name="success">
       </end-state>
      </process-definition>
      

      child
      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition xmlns="urn:jbpm.org:jpdl-3.2"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/xsd/jpdl-3.2.xsd"
       name="childCancel" >
      
       <start-state name="start">
       <transition to="waitingNode"></transition>
       </start-state>
      
      
       <state name="waitingNode">
       <transition to="done" name="success">
       <action expression="#{processStateCancelTest.setVariable('outcome', 'successOutcome')}" />
       </transition>
       <transition to="done" name="failure">
       <action expression="#{processStateCancelTest.setVariable('outcome', 'failOutcome')}" />
       </transition>
       </state>
      
       <end-state name="done">
       </end-state>
      </process-definition>
      


      Here is the full log stack trace when end is called:
      15:24:11,682 INFO [uk.co.iblocks.ProcessStateCancelTest] Ending process 2267 (parentCancel)
      15:24:11,726 INFO [uk.co.iblocks.ProcessStateCancelTest] process-end on ProcessDefinition(childCancel) (process definition ProcessDefinition(childCancel))
      15:24:11,768 INFO [uk.co.iblocks.ProcessStateCancelTest] before-signal on ProcessState(waitForSomething) (process definition ProcessDefinition(parentCancel))
      15:24:11,803 INFO [uk.co.iblocks.ProcessStateCancelTest] node-leave on ProcessState(waitForSomething) (process definition ProcessDefinition(parentCancel))
      15:24:11,836 INFO [uk.co.iblocks.ProcessStateCancelTest] node-enter on Decision(checkOutcome) (process definition ProcessDefinition(parentCancel))
      15:24:11,844 WARN [uk.co.iblocks.ProcessStateCancelTest] Cannot access waitForSomethingOutcome in process parentCancel
      15:24:11,847 DEBUG [uk.co.iblocks.ProcessStateCancelTest] Process parentCancel, returing variable waitForSomethingOutcome=null
      15:24:11,863 FATAL [javax.enterprise.resource.webcontainer.jsf.application] /processTest.xhtml @51,165 action="#{processStateCancelTest.cancel('parentCancel')}": org.jbpm.JbpmException: decision expression '#{processStateCancelTest.getVariable('waitForSomethingOutcome')}' returned null
      javax.faces.el.EvaluationException: /processTest.xhtml @51,165 action="#{processStateCancelTest.cancel('parentCancel')}": org.jbpm.JbpmException: decision expression '#{processStateCancelTest.getVariable('waitForSomethingOutcome')}' returned null
       at org.jbpm.graph.node.Decision.execute(Decision.java:97)
       at org.jbpm.graph.def.Node.enter(Node.java:318)
       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:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
       at org.jbpm.graph.def.Node_$$_javassist_171.enter(Node_$$_javassist_171.java)
       at org.jbpm.graph.def.Transition.take(Transition.java:151)
       at org.jbpm.graph.def.Node.leave(Node.java:393)
       at org.jbpm.graph.node.ProcessState.leave(ProcessState.java:224)
       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:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
       at org.jbpm.graph.def.Node_$$_javassist_171.leave(Node_$$_javassist_171.java)
       at org.jbpm.graph.exe.Token.signal(Token.java:192)
       at org.jbpm.graph.exe.Token.signal(Token.java:168)
       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:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:179)
       at org.jbpm.graph.exe.Token_$$_javassist_107.signal(Token_$$_javassist_107.java)
       at org.jbpm.graph.exe.ProcessInstance.end(ProcessInstance.java:322)
       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:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
       at org.jbpm.graph.exe.ProcessInstance_$$_javassist_176.end(ProcessInstance_$$_javassist_176.java)
       at org.jbpm.graph.exe.Token.notifyParentOfTokenEnd(Token.java:329)
       at org.jbpm.graph.exe.Token.end(Token.java:301)
       at org.jbpm.graph.exe.Token.end(Token.java:251)
       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:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
       at org.jbpm.graph.exe.Token_$$_javassist_107.end(Token_$$_javassist_107.java)
       at org.jbpm.graph.exe.ProcessInstance.end(ProcessInstance.java:302)
       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:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
       at org.jbpm.graph.exe.ProcessInstance_$$_javassist_176.end(ProcessInstance_$$_javassist_176.java)
       at org.jbpm.graph.exe.Token.end(Token.java:283)
       at org.jbpm.graph.exe.Token.end(Token.java:251)
       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:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
       at org.jbpm.graph.exe.Token_$$_javassist_107.end(Token_$$_javassist_107.java)
       at org.jbpm.graph.exe.ProcessInstance.end(ProcessInstance.java:302)
       at uk.co.iblocks.midas.workflow.ProcessStateCancelTest.cancel(ProcessStateCancelTest.java:37)
       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:597)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
       at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
       at org.jboss.seam.util.Work.workInTransaction(Work.java:40)
       at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
       at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
       at uk.co.iblocks.midas.workflow.ProcessStateCancelTest_$$_javassist_12.cancel(ProcessStateCancelTest_$$_javassist_12.java)
       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:597)
       at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
       at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:274)
       at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
       at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
       at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
       at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)