6 Replies Latest reply on Sep 4, 2007 5:27 AM by Olivier Thierry

    Problem with JBPM nodes and transitions

    Olivier Thierry Apprentice

      Hi,

      I use JBPM to model a business process and I want to integrate it with Seam. Part of the process is composed of nodes and transitions, with no interaction with users (actually no task nodes). But for a reason I can't find, one transition can't work ...

      My JBPM process is a very simple one : 3 nodes linked by single transitions and an end state. My JPDL is as following :

      <node name="Node1">
       <transition name="goToNode2" to="Node2">
       <action expression="#{afficherMessageConsole.transition1}" />
       </transition>
       <action expression="#{afficherMessageConsole.goToNode2}" />
      </node>
      <node name="Node2">
       <transition name="goToNode3" to="Node3">
       <action expression="#{afficherMessageConsole.transition2}" />
       </transition>
       <action expression="#{afficherMessageConsole.goToNode3}" />
      </node>
      <node name="Node3">
       <transition name="goToEnd" to="End"></transition>
       <action expression="#{afficherMessageConsole.goToEnd}" />
      </node>
      <end-state name="End"></end-state>


      My actions just write on System.out. I added @org.jboss.seam.annotations.Transition annotation to goToxxx methods, and no annotation for other methods (in fact I added @Transition annotation only to methods binded to nodes, not to transitions).

      When I run this process, the transition between Node1 and Node2 is ok, but transition between Node2 and Node3 doesn't work. The transition2 method is never called ! Note there is nothing in the logs.

      Did I did something wrong ?

      Thanks in advance for your help.

        • 1. Re: Problem with JBPM nodes and transitions
          Pete Muir Master

          The JavaDoc for @Transition states

          Allows the application to set the jBPM transition to be used when an <tt>@EndTask</tt> method is encountered.


          So, nothing to do with transitions between nodes when tasks aren't involved.

          • 2. Re: Problem with JBPM nodes and transitions
            Olivier Thierry Apprentice

            Well it's strange because transition from Node1 to Node2 works well with @Transition ... Anyway, how can I do to fire a transition from an action (method of a Seam component) ?

            • 3. Re: Problem with JBPM nodes and transitions
              Olivier Thierry Apprentice

              To be more precise ...

              When I used JBPM without seam, I had to write these lines in my action handlers so that the process continues :

              public void execute(ExecutionContext context) throws Exception {
               context.leaveNode();
              }


              What should I do with Seam to make it work the same ?

              • 4. Re: Problem with JBPM nodes and transitions
                Olivier Thierry Apprentice

                I found a solution on another post on this forum. I inject processInstance then I can call processInstance.getRootToken().signal() and it works.

                Something like that :

                public class AfficherMessageConsole {
                
                 @In
                 private org.jbpm.graph.exe.ProcessInstance processInstance;
                
                 public void goToNode2() throws Exception {
                 execute("GO TO NODE 2");
                 processInstance.getRootToken().signal();
                 }
                }


                Is it the good way to do it or there is a nicer solution ?

                • 5. Re: Problem with JBPM nodes and transitions
                  Olivier Thierry Apprentice

                  I have another problem with transitions. I have a task-node with 2 transitions "Accepter" and "Refuser". These transitions can be fired from two command buttons in a JSF. These transitions go to nodes with Seam actions binded to them. But when JBPM calls these actions, the processInstance I get with the @In annotation is null ... Why is this processInstance null ?

                  Here is my JSF :

                  <h:dataTable value="#{taskInstanceList}" var="task" rendered="#{not empty taskInstanceList}">
                   <h:column>
                   <f:facet name="header">
                   <h:outputText value="Description"/>
                   </f:facet>
                   <h:outputText value="#{task.description}"/>
                   </h:column>
                   <h:column>
                   <f:facet name="header">
                   <h:outputText value="Effectuée le"/>
                   </f:facet>
                   <h:outputText value="#{task.taskMgmtInstance.processInstance.start}">
                   <f:convertDateTime type="date"/>
                   </h:outputText>
                   </h:column>
                   <h:column>
                   <s:button value="Accepter" action="#{afficherMessageConsole.accepterDemande}" taskInstance="#{task}" />
                   <s:button value="Refuser" action="#{afficherMessageConsole.refuserDemande}" taskInstance="#{task}" />
                   </h:column>
                  </h:dataTable>


                  Here is my Java class :

                  public class AfficherMessageConsole {
                  
                   @In
                   private ProcessInstance processInstance;
                  
                   @StartTask
                   @EndTask (transition="Accepter")
                   public String accepterDemande() throws Exception {
                   return "validationDemandes";
                   }
                  
                   @StartTask
                   @EndTask (transition="Refuser")
                   public String refuserDemande() throws Exception {
                   return "validationDemandes";
                   }
                  
                   public void demandeAcceptee() throws Exception {
                   log("Demande acceptee !");
                   processInstance.getRootToken().signal();
                   }
                  
                   public void demandeRefusee() throws Exception {
                   log("Demande refusee !");
                   processInstance.getRootToken().signal();
                   }
                  }


                  And finally a part of the JPDL :

                  <task-node name="Avis de la RH">
                   <task name="Validation de la RH">
                   <assignment actor-id="#{actor.id}" />
                   </task>
                   <transition name="Refuser" to="Refus"></transition>
                   <transition name="Accepter" to="Acceptation"></transition>
                  </task-node>
                  <node name="Refus">
                   <action expression="#{afficherMessageConsole.demandeRefusee}" />
                   <transition name="" to="End"></transition>
                  </node>
                  <node name="Acceptation">
                   <transition to="End" />
                   <action expression="#{afficherMessageConsole.demandeAcceptee}" />
                  </node>
                  <end-state name="End"></end-state>
                  


                  I looked for samples in the source code, but there are no examples with nodes (and it's a shame). I'm not sure I understood well how to integrate Seam and JBPM, so feel free to tell me if I do something wrong !

                  Thanks in advance ;)

                  • 6. Re: Problem with JBPM nodes and transitions
                    Olivier Thierry Apprentice

                    Anyone could help me ? I really can't understand what happens :(
                    I work with Seam 1.1.6, JBPM 3.1.4 and JBoss 4.0.5 GA