3 Replies Latest reply on Jan 11, 2009 5:00 PM by Ronald van Kuijk

    NullPointerException after signal token in Process State wit

    Kiril Penev Newbie

      Hi guys,

      Recently me and my colleague started learning jBPM for our new project. I have started creating some processes to learn its capabilities.
      We have developed a simple Parent-Children scenario.

      The parent process is:

      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition xmlns="" name="ParentProcess">
       <start-state name="start">
       <transition to="SetInputVariable" name="toSetInputVariable"></transition>
       </start-state>
      
       <process-state name="InvokeChildProcess">
       <sub-process name="ChildProcess" binding="late"></sub-process>
       <variable access="read" name="parentKey"></variable>
       <variable access="read,write" name="lastVisitedProcess"></variable>
       <transition to="PrintVariables" name="toPrintVariables"></transition>
       </process-state>
      
       <node name="SetInputVariable">
       <action class="com.sirma.ecs2.test.subprocess.actions.SetInputVariables"></action>
       <transition to="InvokeChildProcess" name="toInvokeChildProcess"></transition>
       </node>
      
       <node name="PrintVariables">
       <action class="com.sirma.ecs2.test.subprocess.actions.PrintVariables"></action>
       <transition to="end" name="toEnd"></transition>
       </node>
       <end-state name="end"></end-state>
      </process-definition>


      The child process is:
      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition xmlns="" name="ChildProcess">
       <start-state name="start">
       <transition to="Reset Variables" name="toResetVariables"></transition>
       </start-state>
      
       <node name="Reset Variables">
       <action name="Reset Variables" class="com.sirma.ecs2.test.subprocess.actions.ResetVariables"></action>
       <transition to="WaitSignal" name="toWaitSignal"></transition>
       </node>
      
       <state name="WaitSignal">
       <transition to="end" name="toEnd">
       <action class="com.sirma.ecs2.test.subprocess.actions.ExitWait"></action>
       </transition>
       </state>
       <end-state name="end"></end-state>
      </process-definition>


      I start a Parent process and signal it the Token stops at the child`s State node: WaitSignal.
      The Root token of the parent node is in InvokeChildProcess. The ActionHandlers are very simple just print a message and work with some variables.

      If i try to signal the Parent process`s root node i got a NullPointerException:
      Caused by: java.lang.NullPointerException
       at org.jbpm.graph.node.ProcessState.leave(ProcessState.java:186)
       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:173)
       at org.jbpm.graph.def.Node_$$_javassist_49.leave(Node_$$_javassist_49.java)
       at org.jbpm.graph.exe.Token.signal(Token.java:192)
       at org.jbpm.graph.exe.Token.signal(Token.java:140)
       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:173)
       at org.jbpm.graph.exe.Token_$$_javassist_64.signal(Token_$$_javassist_64.java)
       at com.kpenev.test.TestBean.signalToken(Unknown Source)
      


      Probably the right token that i have to signal is the token of the subprocess, but i don`t think that such an exception should occur.

      The code that i execute is:
      JbpmContext jbpmContext = JbpmConfiguration.getInstance()
       .createJbpmContext();
       try {
       ProcessInstance instance = jbpmContext.getGraphSession()
       .loadProcessInstance(instanceID);
       instance.getRootToken().signal();
       } finally {
       jbpmContext.close();
       }


      The code that really works is:
      JbpmContext jbpmContext = JbpmConfiguration.getInstance()
       .createJbpmContext();
       try {
       ProcessInstance instance = jbpmContext.getGraphSession()
       .loadProcessInstance(instanceID);
       instance.getRootToken().getSubProcessInstance().getRootToken()
       .signal();
       } finally {
       jbpmContext.close();
       }


      I`m using jbpm-3.3.0.GA version and jboss-4.2.3.GA.

      I debuged it and the subProcessInstance variable at ExecutionContext isn`t set.

      Hope there is a solution for this, because in the near future i have to develop a very complex processes including subprocesses.