1 Reply Latest reply on Jun 21, 2011 2:32 AM by saig0

    cancel and error end activity throws exception in subprocess [jBPM 4.4]

    saig0 Newbie

      Hi!

       

      I use jBPM 4.4 and created a simple process which includes a state and a subprocess with different end activities:

      process.PNG

      The subprocess is similar to the example in user guide > http://docs.jboss.com/jbpm/v4/userguide/html_single/#endstate .

      subprocess.PNG

       

      When I send the signal "end" to the state in the subprocess, the process wait in state "end state". That's correct!

      But if I send the signal "cancel" or "end", a JbpmException "execution[...] has running subprocess: execution[...] in state cancel/error" throws.

      This exception throws in method checkActive() of the class ExecutionImpl:

       

       if (!isActive())
      protected void checkActive()
          {
              if (!isActive())
              {
                  throw new JbpmException(toString() + " is not active: " + state);
              }
              else if (this.subProcessInstance != null
                      && !Execution.STATE_ENDED.equals(this.subProcessInstance.getState()))
              {
                  throw new JbpmException(toString() + " has running subprocess: "
                          + this.subProcessInstance.toString() + " in state " + this.subProcessInstance.getState());
              }
          }
      

       

      The problem is that the methode only check if the subprocess has the state "end".

      I think the method have to check if the subprocess state is one of {end, cancel, error}. Right?

        • 1. Re: cancel and error end activity throws exception in subprocess [jBPM 4.4]
          saig0 Newbie

          One solution is to change the behavior of class ExecutionImpl to this:

           

           

           

          protected void checkActive()
              {
                  if (!isActive())
                  {
                      throw new JbpmException(toString() + " is not active: " + state);
                  }
                  else if (this.subProcessInstance != null && !isSubProcessEnded())
                  {
                      throw new JbpmException(toString() + " has running subprocess: "
                              + this.subProcessInstance.toString() + " in state " + this.subProcessInstance.getState());
                  }
              }
          
          
              private boolean isSubProcessEnded()
              {
                  List<String> endStates = new ArrayList<String>();
                  endStates.add(Execution.STATE_ENDED);
                  endStates.add("cancel");
                  endStates.add("error");
                  return endStates.contains(this.subProcessInstance.getState());
              }