6 Replies Latest reply on Dec 7, 2005 11:04 AM by for Jbpm

    My workflow doesn't run correctly

    pedro costa Apprentice

      Can anybody test my example, and see if, if my worflows runs correctly? In my pc, the workflows doesn't pass from the first task-node to the second.

      Here is the code:

      package com.sample.jbpm;
      
      import org.jbpm.graph.def.*;
      import org.jbpm.graph.exe.*;
      import org.jbpm.taskmgmt.exe.*;
      
      import com.sample.debug.MyDebug;
      //import org.jbpm.taskmgmt.def.*;
      import java.util.Vector;
      import java.util.Iterator;
      
      public class WorkFlow implements ActionHandler
      {
       private Vector formParameter;
       public ProcessDefinition processDefinition;
       public ProcessInstance processInstance;
       public Token token;
       public TaskInstance taskInstance;
       public Iterator it;
      
       public WorkFlow()
       {
       processDefinition = ProcessDefinition.parseXmlString(
       "<process-definition name='simple'> " +
       " <start-state name='start'> " +
       " <transition name='to_registo_ocorrencia' to='registo_ocorrencia'/> " +
       " </start-state> " +
       " <task-node name='registo_ocorrencia'> " +
       " <task name='RegistoOcorrenciaTask'/> " +
       " <transition name='to_lista_tarefas' to='lista_tarefas'> " +
       " </transition> " +
       " </task-node> " +
       " <task-node name='lista_tarefas'> " +
       " <task name='ListaTarefasTask'/> " +
       " <transition name='to_notificacoes' to='notificacoes'/> " +
       " </task-node> " +
       " <task-node name='notificacoes'> " +
       " <task name='NotificacoesTask'/> " +
       " <transition name='to_end' to='end'/> " +
       " </task-node> " +
       " <end-state name='end'/> " +
       "</process-definition> "
       );
      
       /* ProcessInstance is one execution of a ProcessDefinition */
       processInstance = new ProcessInstance(processDefinition);
       /* represents one path of execution */
       token = processInstance.getRootToken();
       token.signal();
      
       }
      
      
       public void RegistoOcorrenciaTask()
       {
       /* taskInstance is one task instance that can be assigned to an actor */
       taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next();
      
       /**
       * RegistoOcorrenciaTask
       **/
       if(taskInstance.getName().equals("RegistoOcorrenciaTask"))
       {
       // Já tenho que ter os parâmetros inicializados
       //formParameter = (Vector) taskInstance.getTaskFormParameters();
      
       MyDebug.print("xxxxxxxxxx RegistoOcorrenciaTask xxxxxxxxxxx");
       MyDebug.print("getName()\t--> " +taskInstance.getName());
       MyDebug.print("isSignalling()\t--> " +taskInstance.isSignalling());
       MyDebug.print("isBlocking()\t--> " +taskInstance.isBlocking());
      
      
       //Daqui posso chamar outras funções java para tratar os argumentos.
       taskInstance.end();
       MyDebug.print("hasEnded()\t--> " +taskInstance.hasEnded());
       MyDebug.print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
      
      
       }
       }
      
       public void ListaTarefasTask()
       {
       taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next();
      
       System.out.println("TASKINSTANCE " + taskInstance.getName());
       /**
       * ListaTarefasTask
       */
       if(taskInstance.getName().equals("ListaTarefasTask"))
       {
       //taskInstance.setActorId("User");
      
      
       MyDebug.print("############# ListaTarefasTask ###########");
       MyDebug.print("getName()\t--> " +taskInstance.getName());
       MyDebug.print("isSignalling()\t--> " +taskInstance.isSignalling());
       MyDebug.print("isBlocking()\t--> " +taskInstance.isBlocking());
       taskInstance.end();
       MyDebug.print("hasEnded()\t--> " +taskInstance.hasEnded());
       }
       }
      
       public void NotificacoesTask()
       {
      
      
       taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next();
       /**
       * NotificacoesTask
       */
       if(taskInstance.getName().equals("NotificacoesTask"))
       {
      
       MyDebug.print("############# NotificacoesTask ###########");
       MyDebug.print("getName()\t--> " +taskInstance.getName());
       MyDebug.print("isSignalling()\t--> " +taskInstance.isSignalling());
       MyDebug.print("isBlocking()\t--> " +taskInstance.isBlocking());
       taskInstance.end();
       MyDebug.print("hasEnded()\t--> " +taskInstance.hasEnded());
       }
       }
      
       public ProcessDefinition getProcessDefinition()
       {
       return processDefinition;
       }
      
       public ProcessInstance getProcessInstance()
       {
       return processInstance;
       }
      
       public Token getToken()
       {
       return token;
       }
      
       public TaskInstance getTaskInstance()
       {
       return taskInstance;
       }
      
       /**
       * Retorna um vector com todos os parametros
       * indicados no registo de ocorrencia
       * @return Vector
       */
       public Vector getFormParameter()
       {
       return formParameter;
       }
      
      
      
       public static void main(String[] args){
       WorkFlow wf = new WorkFlow();
       wf.RegistoOcorrenciaTask();
       wf.ListaTarefasTask();
       wf.NotificacoesTask();
       }
      
      
       public void execute(ExecutionContext executionContext) throws Exception {
       MyDebug.print("------> ENTROU NO EXECUTE <---------");
       executionContext.leaveNode();
      
       }
      }
      
      


      The output is:

      xxxxxxxxxx RegistoOcorrenciaTask xxxxxxxxxxx
      getName() --> RegistoOcorrenciaTask
      isSignalling() --> true
      isBlocking() --> false
      hasEnded() --> true
      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      TASKINSTANCE RegistoOcorrenciaTask
      log4j:WARN No appenders could be found for logger (org.jbpm.jpdl.xml.JpdlXmlReader).
      log4j:WARN Please initialize the log4j system properly.
      



      Can anybody understand why this happens?

      Please, I'm desperate.

      Thanks.

        • 1. Re: My workflow doesn't run correctly
          pedro costa Apprentice

          I've working on this example, for too many of days, and still can't find the problem.

          Any help?

          Thanks

          • 2. Re: My workflow doesn't run correctly
            Ronald van Kuijk Master

            you need to retrieve the unfinished taskinstances. Look in the api. It is a different method. The token is probly in the next state. and your process is working fine, it's just that you retrieve an already finished task

            • 3. Re: My workflow doesn't run correctly
              for Jbpm Novice

              Hi!
              Could you please explain this a bit?
              I am sorry about it but the process definitions I have already deployed are just stuck in one state.
              processInstance.signal() is supposed to move the WF from one state to next state?? (Is it right?) Thats what the impression I had!
              If One of my state (in WF) dosent have any task or action associated with it. How will it proceed to next state?
              Please explain this a bit.
              I am really confused at this stage.
              Thanks!

              • 4. Re: My workflow doesn't run correctly
                for Jbpm Novice

                When I try to debug my processdefinition. I Console window I see that its going in a somekind of loop. and I get following messages in the console window repeatadly!! I am really not able to find any reson for this. May be looking at console output you can give me some ideas?
                This may be the reason for my processdefinition getting stuck in one state!
                Please Help!

                15:09:45,844 WARN JpdlXmlReader : process xml warning: warning: no swimlane or assignment specified for task '<task xmlns="http://jbpm.org/3/jpdl" blocking="false" priority="normal">
                 <controller>
                 <variable name="message" access="read,write"/>
                 </controller>
                 </task>'
                15:09:45,895 DEBUG GraphElement : event 'process-start' on 'ProcessDefinition(ECSDemo3)' for 'Token(/)'
                15:09:46,088 DEBUG GraphElement : event 'before-signal' on 'StartState(startECSFlow)' for 'Token(/)'
                15:09:46,139 DEBUG GraphElement : event 'node-leave' on 'StartState(startECSFlow)' for 'Token(/)'
                15:09:46,189 DEBUG GraphElement : event 'transition' on 'Transition(1d008ff)' for 'Token(/)'
                15:09:46,240 DEBUG GraphElement : executing action 'action[action]'
                15:09:46,434 WARN JpdlXmlReader : process xml warning: warning: no swimlane or assignment specified for task '<task xmlns="http://jbpm.org/3/jpdl" blocking="false" priority="normal">
                 <controller>
                 <variable name="message" access="read,write"/>
                 </controller>
                 </task>'


                • 5. Re: My workflow doesn't run correctly
                  Ronald van Kuijk Master

                  @pedrosacosta:

                  taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next();

                  gives you the first taskInstance of this process, not the UNFINISHED taskInstances. A modern IDE has codecompletion, where you can see

                  taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance().getUnfinishedTasks(taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance().getUnfinishedTasks(processInstance.getRootToken()).iterator().next();).iterator().next();

                  is also possible. This will give you the unfinished tasks so you can signal that one, instead of the already completed one. We are thinking of returning an error when an already completed task is signalled, but that will not be in the 3.1 release.

                  @forJbpm:

                  Sorry, I cannot help you since I have no idea what your real problem is. And please do not start a new unrelated question in an already existing thread. That is confusing to us and other users.

                  • 6. Re: My workflow doesn't run correctly
                    for Jbpm Novice

                    I am reallly sorry for confusing everyone.
                    But I thought that problem is related so I posted it in the same thread as I am doing it in similar way.
                    Anyways, Again sorry for all the confusion!