10 Replies Latest reply on Nov 8, 2006 9:24 PM by Saravanan Bellan

    Problem running process state inside a process

    David Hosier Novice

      I have a process that contains a process state pointing to another process. When I run the process and it gets to the process state, it seems to have just blown right through the subprocess without stopping at the wait states and assigning the tasks contained within. For example, my test process asks for numbers and then does some math. So the process just ran right through until it got a NumberFormatException trying to do math with null, since it never assigned the tasks to the user to get the numbers. Is this a limitation in 3.1? Thanks.

        • 1. Re: Problem running process state inside a process
          Akshay Sharma Newbie

          Hi Can u tell me how to use Process State.

          I am trying to execute a Process State but my flow gets into the sub process but is unabkle to come back to the parent

          • 2. Re: Problem running process state inside a process
            David Hosier Novice

            I just read the Process Composition section (http://docs.jboss.org/jbpm/v3/userguide/processmodelling.html#processcomposition) in the documentation. It seems to imply the behavior that I am seeing, where the subprocess just runs straight through. Is this correct behavior. If so, what is the reason for this? Why does a subprocess not behave like it would if run on its own? Thanks.

            • 3. Re: Problem running process state inside a process
              David Hosier Novice

              I almost missed your question. Did you specify the transition out of the process state to the next state in the workflow? My state looks like the following, where "end1" is the next state in the flow:

               <process-state name="David">
               <sub-process name="david" />
               <variable name="FirstName" />
               <variable name="LastName" />
               <transition name="" to="end1"></transition>
               </process-state>
              


              • 4. Re: Problem running process state inside a process
                David Hosier Novice

                Hmm, I thought this would be an easy question to get answered by the developers. If nobody knows the answer, does anybody know of some resource that would give me some definitive clues? Thanks.

                • 5. Re: Problem running process state inside a process
                  Koen Aers Master

                  Can you at least post your process and your subprocess here? Better yet, also post a unit test demonstrating the behaviour?
                  Without this info it is quite difficult to see what is going on.

                  Regards,
                  Koen

                  • 6. Re: Problem running process state inside a process
                    David Hosier Novice

                    I can do that when I get to work tomorrow, but the basic question is if the behavior I'm seeing is the way it is supposed to work or not. Surely that can be answered without seeing process definitions. When I run the sub-process as its own process, it stops at wait states and doesn't resume until assigned actors finish the tasks. When I run it as a subprocess, it just goes right through without ever assigning tasks and waiting. Your response implies it should stop at the wait states, and I am doing something wrong. So I will post the processes as soon as possible. Thanks.

                    • 7. Re: Problem running process state inside a process
                      David Hosier Novice

                      I was just using the bundled web application to run my process, so I have no unit test. Here are my processes.
                      Process that contains the sub-process:

                      <?xml version="1.0" encoding="UTF-8"?>
                      
                      <process-definition
                       xmlns="urn:jbpm.org:jpdl-3.1" name="super">
                       <swimlane name="User">
                       <assignment expression="user(bert)"></assignment>
                       </swimlane>
                       <super-state name="GetName">
                       <task-node name="GetFirstName">
                       <task name="task1" swimlane="User">
                       <controller>
                       <variable name="FirstName"></variable>
                       </controller>
                       </task>
                       <transition name="" to="GetlastName"></transition>
                       </task-node>
                       <task-node name="GetlastName">
                       <task name="task1" swimlane="User">
                       <controller>
                       <variable name="LastName"></variable>
                       </controller>
                       </task>
                       </task-node>
                       <transition name="" to="David"></transition>
                       </super-state>
                       <start-state name="start">
                       <task name="GetStarted" swimlane="User">
                       <controller>
                       <variable name="Pet"></variable>
                       </controller>
                       </task>
                       <transition name="" to="GetName"></transition>
                       </start-state>
                       <end-state name="end1"></end-state>
                       <process-state name="David">
                       <sub-process name="david" />
                       <variable name="FirstName" />
                       <variable name="LastName" />
                       <transition name="" to="end1"></transition>
                       </process-state>
                      </process-definition>
                      


                      The sub-process.
                      <?xml version="1.0" encoding="UTF-8"?>
                      
                      <process-definition
                       xmlns="urn:jbpm.org:jpdl-3.1" name="david">
                       <swimlane name="Son">
                       <assignment expression="user(bert)"></assignment>
                       </swimlane>
                       <swimlane name="Father">
                       <assignment expression="user(ernie)"></assignment>
                       </swimlane>
                       <start-state name="start">
                       <task name="StartTask" swimlane="Father">
                       <controller>
                       <variable name="FirstName"></variable>
                       <variable name="LastName"></variable>
                       <variable name="FirstNumber"></variable>
                       <variable name="SecondNumber"></variable>
                       </controller>
                       </task>
                       <transition name="DoMath" to="AreYouRich">
                       <action name="SayHello" class="com.sample.action.WelcomeMessageActionHandler">
                       <message>Welcome to my process ${firstName} ${lastName}!</message>
                       </action>
                       </transition>
                       </start-state>
                       <end-state name="end">
                       <event type="node-enter">
                       <action name="PeaceOut" class="com.sample.action.MessageActionHandler">
                       <message>Peace out!</message>
                       </action>
                       </event>
                       </end-state>
                       <decision name="AreYouRich">
                       <event type="node-enter">
                       <action name="CalculateWealth" class="com.sample.action.MathActionHandler"></action>
                       </event>
                       <transition name="No" to="end">
                       <condition expression="#{contextInstance.variables.sum le 100}" />
                       <action name="ForgetYou" class="com.sample.action.MessageActionHandler">
                       <message>Forget you then, you loser.</message>
                       </action>
                       </transition>
                       <transition name="Yes" to="AskForMoney">
                       <condition expression="#{contextInstance.variables.sum gt 100}" />
                       </transition>
                       </decision>
                       <task-node name="AskForMoney">
                       <task name="GetMoney" swimlane="Son">
                       <controller>
                       <variable name="HowMuchMoney"></variable>
                       </controller>
                       </task>
                       <transition name="Thanks" to="end">
                       <action name="Thanks" class="com.sample.action.MessageActionHandler">
                       <message>Thanks for the dough pops.</message>
                       </action>
                       </transition>
                       </task-node>
                      </process-definition>
                      


                      • 8. Re: Problem running process state inside a process
                        David Hosier Novice

                        Ok, when I was posting the process definitions, I realized something. One of the tasks that the execution was not stopping at was the task set on the start state of the sub-process. I put that there so I could execute that process stand alone in the web application. I assume that the fact it doesn't assign that task when run as a sub-process has something to do with the nature of how subprocesses are started. I also realized that the reason it did not stop on the AskForMoney task is that the FirstNumber and SecondNumber variables were never filled in (since it didn't stop at the StartTask in the david process). Thus the AreYouRich decision never traversed the"yes" transition to the AskForMoney task. I added those two variables to a task in the main process and passed them into the sub-process and tested it again. This time it successfully moved from the AreYouRich node to the AskForMoney node and assigned it to the correct user and waited for input. So now the question is just why does the sub-process not get that task assigned which is attached to the start state?

                        • 9. Re: Problem running process state inside a process
                          Koen Aers Master

                          Because the task in the start-state serves to inject some variable values into the process. When run as a subprocess, you can inject those values with the variable passing mechanism of the process-state node.

                          Regards,
                          Koen

                          • 10. Re: Problem running process state inside a process
                            Saravanan Bellan Newbie

                            Koen,

                            If I have a 'initiator' swimlane in the sub-process, will the initiator be populated from parent process. This does not seem to be happening. I get 'null' if I try to get the user associated with swimlane 'initiator' in the sub-process.

                            Thanks,