1 2 Previous Next 17 Replies Latest reply on Jun 5, 2007 8:50 AM by Edward Staub

    Problem in getting proper workflow transitions:

    max pot Newbie

      Hi everyone,

      I am a new user to jbpm and i am stuck in getting a problem resolved. I would appreciate any help on the same.

      I basically wanted to a process to wait at a task-node for user input and then move to next state on signal.

      So I created a process definition which has the following states
      1.) start
      2) task-node1
      3) task-node2
      4) task-node3
      5)end

      Now if i execute the following code in a servlet

      ProcessInstance processInstance1 = new ProcessInstance(processDefinition2);

      Token token2 = processInstance1.getRootToken();
      print(token2.getNode().getName());
      token2.signal();
      print(token2.getNode().getName());
      token2.signal();

      print(token2.getNode().getName());
      token2.signal();
      print(token2.getNode().getName());
      token2.signal();

      It prints, start, task-node1, task-node2, task-node3

      But say
      after

      Token token2 = processInstance1.getRootToken();
      print(token2.getNode().getName());
      token2.signal();
      print(token2.getNode().getName());

      i save the process instance, with the token

      now i again reload the process insatnce with its id in a seperate servlet and execute the following code

      print(token2.getNode().getName());
      Token token2 = processInstance1.getRootToken();
      print(token2.getNode().getName());

      i get
      task-node1
      end

      shouldn't the state be changed to task-node2 ????

      Anyone faced similar problem. If you would like me to try something , do let me know.

      - Max

        • 1. Re: Problem in getting proper workflow transitions:
          Duc Newbie

          Can you also post the processdefinition.xml?

          Cheers,
          Duc

          • 2. Re: Problem in getting proper workflow transitions:
            Ronald van Kuijk Master

            why do you assume it should be in task-node2? How does it even get to end, you don't even signal it..etc...etc... so please, never post partial processdefinitions and partial code....

            • 3. Re: Problem in getting proper workflow transitions:
              max pot Newbie

              Hi Duc

              Here is the process definition.xml file for the same

              <process-definition
              xmlns="urn:jbpm.org:jpdl-3.1" name="credit-request-approval">

              <start-state name="start">

              </start-state>

              <task-node name="task-node1">


              </task-node>
              <task-node name="task-node2">



              </task-node>
              <task-node name="task-node3">



              </task-node>
              <end-state name="Request Approved"></end-state>
              <end-state name="Request rejected"></end-state>
              </process-definition>

              • 4. Re: Problem in getting proper workflow transitions:
                max pot Newbie

                Hi Duc

                Here is the process definition.xml file for the same

                <process-definition
                xmlns="urn:jbpm.org:jpdl-3.1" name="credit-request-approval">

                <start-state name="start">

                </start-state>

                <task-node name="task-node1">


                </task-node>
                <task-node name="task-node2">



                </task-node>
                <task-node name="task-node3">



                </task-node>
                <end-state name="Request Approved"></end-state>
                <end-state name="Request rejected"></end-state>
                </process-definition>

                • 5. Re: Problem in getting proper workflow transitions:
                  max pot Newbie

                  Hi Duc

                  Here is the process definition.xml file for the same

                  <process-definition
                   xmlns="urn:jbpm.org:jpdl-3.1" name="credit-request-approval">
                  
                   <start-state name="start">
                   <transition name="enter-request" to="task-node1"></transition>
                   </start-state>
                  
                   <task-node name="task-node1">
                   <task name="enter-details" ></task>
                   <transition name="send for approval" to="task-node2"></transition>
                   </task-node>
                   <task-node name="task-node2">
                   <task name="approval1"></task>
                   <transition name="approved" to="task-node3"></transition>
                   <transition name="rejected" to="Request rejected"></transition>
                   </task-node>
                   <task-node name="task-node3">
                   <task name="approval2"></task>
                   <transition name="approved" to="Request Approved"></transition>
                   <transition name="rejected" to="Request rejected"></transition>
                   </task-node>
                   <end-state name="Request Approved"></end-state>
                   <end-state name="Request rejected"></end-state>
                  </process-definition>


                  • 6. Re: Problem in getting proper workflow transitions:
                    max pot Newbie

                    Hi kukeltje,

                    I assumed that it would be in task-node 2 because a signal should move state from one node to another , is'nt it.

                    Lets say i start a process , signal to move to next state and store it. Then when later on say i reload the instance again and does another signal it should go to next state, but in my case in the latter scenario, it jumps to the end state. I just fail to understand whats happening here.

                    Do i need to maintain some information somewhere. i doubt that, but asked just incase.

                    -Max

                    • 7. Re: Problem in getting proper workflow transitions:
                      Duc Newbie


                      You can see in the debug output log what really happened.

                      Duc

                      • 8. Re: Problem in getting proper workflow transitions:
                        max pot Newbie

                        Ok. let me ask a different question
                        [ I am unable to find anything useful from debug logs, I posted here after checking all that only]

                        Lets say i create a taskInstance like this
                        TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();

                        // Save the process instance along with the task instance
                        jbpmContext.save(processInstance);


                        Now say the user performs some task on this instance and a UI event is created to move to next state,

                        I load the taskInstance based on its id
                        TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(taskInstanceId);

                        Then i do
                        taskInstance.end(transitionName);

                        This finishes the current task. But new tasks or anything is created.

                        How would the task in next state created in db. ??? And how can i check whether the state has moved to next state.

                        If i do
                        ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
                        and processInstance.signal() - > the rootToken.node.name shows end-state

                        But i want process to go on next state ? so signal goes out of the picture.

                        Any ideas ducn/kukeltje ??

                        -Max

                        • 9. Re: Problem in getting proper workflow transitions:
                          max pot Newbie

                          Editing last few lines
                          This finishes the current task. But "NO" new tasks or anything is created.

                          How would the task in next state created in db. ??? And how can i check whether the state has moved to next state.

                          If i do
                          ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
                          and processInstance.signal() - > the rootToken.node.name shows end-state

                          But i want process to go on next state ? so signal goes out of the picture.

                          Any ideas ducn/kukeltje ??

                          -Max

                          • 10. Re: Problem in getting proper workflow transitions:
                            max pot Newbie

                            Ok let me give a concrete example:

                            <process-definition
                             xmlns="urn:jbpm.org:jpdl-3.1" name="credit-request-approval">
                            
                             <start-state name="start">
                             <task name="task-node1" ></task>
                             <transition name="send for approval" to="task-node2">
                             </start-state>
                            
                             </task-node>
                             <task-node name="task-node2">
                             <task name="approval1"></task>
                             <transition name="approved" to="task-node3"></transition>
                             <transition name="rejected" to="Request rejected"></transition>
                             </task-node>
                             <task-node name="task-node3">
                             <task name="approval2"></task>
                             <transition name="approved" to="Request Approved"></transition>
                             <transition name="rejected" to="Request rejected"></transition>
                             </task-node>
                             <end-state name="Request Approved"></end-state>
                             <end-state name="Request rejected"></end-state>
                            </process-definition>
                            


                            if i do
                            {
                            
                             ProcessInstance processInstance = new ProcessInstance(processDefinition2);
                             TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
                             taskInstance.start();
                             context.save(processInstance);
                            
                             Token token = processInstance.getRootToken();
                             System.out.println(token.getNode().getName() + " <br><br>");
                            
                             taskInstance.end("send for approval");
                            
                             token = processInstance.getRootToken();
                             System.out.println(token.getNode().getName() + " <br><br>");
                            }
                            


                            2 task instances are created for me
                            start and task-node2


                            But, say i do something like this

                            
                             ProcessInstance processInstance = new ProcessInstance(processDefinition2);
                             TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
                             taskInstance.start();
                             context.save(processInstance);
                            


                            and in a seperate servlet i do
                             TaskMgmtSession taskMgmtSession = context.getTaskMgmtSession();
                             TaskInstance taskInstance = context.loadTaskInstanceForUpdate(1L);
                             taskInstance.end("send for approval");
                            



                            then only the start taskinstance is created.

                            Any ideas why this might be the case.

                            Is it something related to same context or something ? Any ideas how i can achieve this .

                            I must mention i am creating seperate contexts in these different servlets if that might be the case. I am really unsure of this behaviour .

                            Ideas ? ?

                            - MAx




                            • 12. Re: Problem in getting proper workflow transitions:
                              Edward Staub Expert

                              I think you forgot to jbpmContext.close().

                              -Ed Staub

                              • 13. Re: Problem in getting proper workflow transitions:
                                max pot Newbie

                                Nopes i have done that.
                                I have checked the same twice and i am closing the context properly.

                                -Max

                                • 14. Re: Problem in getting proper workflow transitions:
                                  Edward Staub Expert

                                   

                                  TaskInstance taskInstance = context.loadTaskInstanceForUpdate(1L);



                                  1L??? What the L is 1L?

                                  -Ed Staub

                                  1 2 Previous Next