4 Replies Latest reply on Jul 18, 2006 11:57 AM by asmo

    Problem with task assignment

    asmo

      Hello!
      I have written a little processdefinition and executed it in a jUnit test. Everything is ok and no failure occured.
      But the assignment handler of the task node is excecuted twice and i have no clue why.
      Could anyone give me an advise???

      This is the processDefinition:

      <process-definition
       name="crmTest">
       <start-state name="start">
       <transition name="to_createActivity" to="createActivity"></transition>
       </start-state>
       <state name="createActivity">
       <event type="before-signal">
       <action name="action1" class="createActionHandler"></action>
       </event>
       <transition name="to_handleActivity" to="handleActivity"></transition>
       </state>
       <task-node name="handleActivity"
       >
       <task name="task1">
       <assignment class="activityAssignment"></assignment>
       </task>
       <transition name="tr2" to="createActivity"></transition>
       <transition name="to_end" to="end"></transition>
       </task-node>
       <end-state name="end"></end-state>
      </process-definition>


      this is the code of the jUnit test:

      public class HelloWorldDbTest extends TestCase{
      
       static JbpmConfiguration jbpmConfiguration = null;
      
       static {
      
       jbpmConfiguration = JbpmConfiguration.parseResource("jbpm1.cfg.xml");
      
      
       }
       public void setUp(){
       jbpmConfiguration.createSchema();
      
       }
       public void tearDown(){
       // jbpmConfiguration.dropSchema();
       }
       public void testSimplePersistence(){
       deployProcessDefinition();
       assign();
      
       }
      
       public void deployProcessDefinition(){
      
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("processdefinition.xml");
       System.out.println("name of the processdefinition: " + processDefinition.getName());
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
      
       try{
       jbpmContext.deployProcessDefinition(processDefinition);
       }finally{
       jbpmContext.close();
       }
       }
       public void assign(){
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try{
       GraphSession graphSession = jbpmContext.getGraphSession();
       ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("crmTest");
      
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
      
       Token token = processInstance.getRootToken();
      
       assertEquals("start", token.getNode().getName());
      
      
       token.signal();
       assertEquals("createActivity" , token.getNode().getName(),"createActivity");
      
       token.signal();
       assertEquals("handleActivity ", token.getNode().getName(), "handleActivity");
      
       Collection tasks = processInstance.getTaskMgmtInstance().getTaskInstances();
       Iterator it = tasks.iterator();
      
       while(it.hasNext()){
       TaskInstance taskInstance = (TaskInstance)it.next();
       System.out.println("Taskinstance " + taskInstance.getId() + " finished");
       taskInstance.end("to_end");
       }
      
       assertEquals("end expected", token.getNode().getName(), "end");
      
       jbpmContext.save(processInstance);
      
       }finally {
       jbpmContext.close();
      
       }
       }
      
      


      and at least the output of the console:


      15:44:48,390 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Node]; using defaults.
      15:44:48,453 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.instantiation.Delegation]; using defaults.
      15:44:48,625 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.taskmgmt.def.Task]; using defaults.
      15:44:48,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.ProcessDefinition]; using defaults.
      15:44:48,875 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.ExceptionHandler]; using defaults.
      15:44:48,890 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.module.def.ModuleDefinition]; using defaults.
      15:44:49,156 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Action]; using defaults.
      15:44:49,203 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Event]; using defaults.
      15:44:49,406 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.context.def.VariableAccess]; using defaults.
      15:44:49,515 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Transition]; using defaults.
      15:44:49,734 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.taskmgmt.def.TaskController]; using defaults.
      15:44:49,734 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.taskmgmt.def.TaskMgmtDefinition.tasks]; using defaults.
      15:44:49,750 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.node.ProcessState.variableAccesses]; using defaults.
      15:44:49,750 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.ProcessDefinition.events]; using defaults.
      15:44:49,750 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.taskmgmt.def.Swimlane.tasks]; using defaults.
      15:44:49,750 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Node.leavingTransitions]; using defaults.
      15:44:49,750 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.taskmgmt.def.TaskController.variableAccesses]; using defaults.
      15:44:49,750 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.ProcessDefinition.exceptionHandlers]; using defaults.
      15:44:49,750 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.node.Decision.decisionConditions]; using defaults.
      15:44:49,765 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.file.def.FileDefinition.processFiles]; using defaults.
      15:44:49,765 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Transition.exceptionHandlers]; using defaults.
      15:44:49,765 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.ProcessDefinition.actions]; using defaults.
      15:44:49,765 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.ProcessDefinition.nodes]; using defaults.
      15:44:49,765 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Node.arrivingTransitions]; using defaults.
      15:44:49,765 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.node.TaskNode.tasks]; using defaults.
      15:44:49,765 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.ProcessDefinition.definitions]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Event.actions]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.taskmgmt.def.Task.events]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Node.events]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.taskmgmt.def.TaskMgmtDefinition.swimlanes]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.SuperState.nodes]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.action.Script.variableAccesses]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.ExceptionHandler.actions]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.taskmgmt.def.Task.exceptionHandlers]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Node.exceptionHandlers]; using defaults.
      15:44:49,781 WARN EhCacheProvider:103 - Could not find configuration [org.jbpm.graph.def.Transition.events]; using defaults.
      name of the processdefinition: crmTest
      15:44:51,125 WARN ProxyWarnLog:654 - Narrowing proxy to class org.jbpm.graph.node.State - this operation breaks ==
       hier angekommen
      15:44:51,468 WARN ProxyWarnLog:654 - Narrowing proxy to class org.jbpm.graph.node.TaskNode - this operation breaks ==
       Task assigned
       Task assigned
      Taskinstance 1 finished
      Taskinstance 2 finished
      


      I would be very thankful for an advice!

        • 1. Re: Problem with task assignment
          kukeltje

          what does the create activity classs do? Does it by 'accident' create another task?

          • 2. Re: Problem with task assignment
            asmo

            Thank you for the quick reply!
            In the createActivity state is the createActionHandler called on the before-signal event.

            I have deleted all the code to avoid such "accidents", so that the actionHandler just call a transition to leave the node.

            import org.jbpm.graph.def.ActionHandler;
            import org.jbpm.graph.exe.ExecutionContext;
            
            public class createActionHandler implements ActionHandler {
            
             public void execute(ExecutionContext arg0) throws Exception {
             // TODO Auto-generated method stub
            
            
             arg0.getNode().leave(arg0,"to_handleActivity");
            
            
             }
            
            }
            




            • 3. Re: Problem with task assignment
              kukeltje

              I think you created a small loop....

              you have an actionhandler on a state signal that state (you should not do that, only in a node or decsion) AND you signal the state separately in your testcase. That way the TR2 is taken and an additional task is created. So the behaviour is in my opinion correct.

              You could see this in the logging btw that tr2 is taken as a default transition somewhere.

              • 4. Re: Problem with task assignment
                asmo

                Yes, that was the problem.
                Thank you very much!!!!