5 Replies Latest reply on Nov 28, 2009 2:35 AM by Mas Mohktar

    Using Drools for jBPM decision

    turpin vincent Newbie

      Hi,


      I'm starting to use Seam and i've got some problems using Drools in order to manage decisions in my process.


      Configuration
      Jboss 5.0.0 GA
      Seam 2.1.1 GA
      Ant 1.7
      Jboss Tool
      Eclipse 3.4


      When i use Drools to manage assignment, it works fine, but now i would like to use it for decison managment and i got this error:


      Exception during request processing: 
      Caused by javax.el.ELException with message: "org.jbpm.JbpmException: decision 'decision69' selected non existing transition 'null'" 



      I give you a part of my code but if something else is needed tell me.



      Process:


             <task-node name="PlaceOrder">
                      <task name="placeOrderTask">
                              <assignment class="org.jboss.seam.drools.DroolsAssignmentHandler">
                          <workingMemoryName>securityRulesWorkingMemory</workingMemoryName>       
                          <assertObjects>       
                              <element>#{orderStock}</element>    
                          </assertObjects>      
                              </assignment>
                      </task>
                      <transition name="cancel" to="error" />
                      <transition to="decision69" name="todecision"></transition>
              </task-node>
      
              <decision name="decision69">
                      
                      <handler class="org.jboss.seam.drools.DroolsDecisionHandler">
                              <workingMemoryName>accountApprovalWorkingMemory</workingMemoryName>
                              <assertObjects>
                                      <element>#{actor}</element>
                                      <element>#{orderStock}</element>
                              </assertObjects>
                      </handler>
                      
                      <transition to="Deliver" name="toDeliver">
                              <action  class="org.jboss.seam.drools.DroolsActionHandler">
                                      <workingMemoryName>accountApprovalWorkingMemory</workingMemoryName>
                                      <assertObjects>
                                              <element>#{actor}</element>
                                              <element>#{orderStock}</element>
                                      </assertObjects>
                              </action >
                      </transition>
                      <transition to="end" name="toend"></transition>
              </decision>
      
      
              <task-node name="Deliver">
                      <task name="getFromStock">
                              <assignment actor-id="#{actor.id}" />
                      </task>
                      <transition name="next" to="end" />
                      <transition name="cancel" to="error" />
              </task-node>




      Component.xml:




      <persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                                entity-manager-factory="#{testEntityManagerFactory}"/>
      
         <persistence:entity-manager-factory name="testEntityManagerFactory"
                            persistence-unit-name="test"/>
      
         <drools:rule-base name="securityRules">
            <drools:rule-files><value>/security.drl</value></drools:rule-files>
         </drools:rule-base>
         
         <drools:managed-working-memory name="securityRulesWorkingMemory" auto-create="true" rule-base="#{securityRules}"/>
         
         <security:rule-based-permission-resolver security-rules="#{securityRules}"/>
         
         <drools:rule-base name="accountApprovalRules">
                      <drools:rule-files>
                      <value>/accountApproval.drl</value>
              </drools:rule-files>
         </drools:rule-base>
              
         <drools:managed-working-memory name="accountApprovalWorkingMemory" auto-create="true" rule-base="#{accountApprovalRules}"/>
         




      AccountAproval.drl:



      package AccountApproval;
      
      
      import org.jboss.seam.bpm.Actor;  
      import org.domain.test.session.OrderStock;
      import org.jboss.seam.drools.Decision;
      
      global Decision decision
      
      rule "Approve Order For Loyal Customer"
        when
              OrderStock ( processQuantity >= 0 )
        then
          System.out.println("plooooooooooop");
          decision.setOutcome("toDeliver");
      end
      




        • 1. Re: Using Drools for jBPM decision
          turpin vincent Newbie

          So i would like to know if someone can tell me why it happends.


          thank's by advance


          And i'm sorry for my english witch isn't as fine sa i would like (I'm a french student) and for replying myself (I didn't find how to edit my post)

          • 2. Re: Using Drools for jBPM decision
            Ingo Jobling Master

            Bonjour Vincent,


            Have you enabled debug for Drools, which should produce some more detailed message on the console?


            Salutations!

            • 3. Re: Using Drools for jBPM decision
              Ingo Jobling Master

              If the rule doesn't evaluate to setOutcome(toDeliver), it will return null?

              • 4. Re: Using Drools for jBPM decision
                turpin vincent Newbie

                bonjour,


                First thanks for answering me so fast and these few words in french. I haven't enabled debug but i'm going to and i will post then more information. For the moment i just can add that the file AccountAproval.drl is correctly parsed and the probleme seems to come from the data handler witch return null in spite of toDeliver or toEnd. If it can help i'm working from these two examples: http://docs.jboss.com/seam/latest/reference/en-US/html/drools.html (chapter 14.3) and http://www.jboss.org/community/docs/DOC-11096.


                In addition, actually if the rule doesn't evaluate to setOutcome(toDeliver), it return null but i think that the condition in the rule is evaluated (if the syntaxe condition isn't correct i get an error about that).


                I give my java class too (mabe it will help) i think that the problem can come from the fact taht i dont know if i have to declare again the data handler in this class or if the descrption in the process is enough.




                package org.domain.test.session;
                
                 import org.jboss.seam.annotations.bpm.CreateProcess;  
                 import org.jboss.seam.annotations.bpm.EndTask;  
                 import org.jboss.seam.annotations.Name;  
                 import org.jboss.seam.annotations.bpm.StartTask;  
                 import org.jboss.seam.annotations.*;  
                 import org.jboss.seam.ScopeType;  
                   
                 @Name("orderStock")   
                 public class OrderStock  
                 {  
                    
                    @Out(scope=ScopeType.BUSINESS_PROCESS, required=false)  
                    Long processQuantity;  
                      
                    public Long getProcessQuantity() {
                          return processQuantity;
                     }
                
                     public void setProcessQuantity(Long processQuantity) {
                          this.processQuantity = processQuantity;
                     }
                
                     private int quantity ;  
                        
                    public int getQuantity()  
                    {  
                       return quantity;  
                    }  
                   
                    public void setQuantity(int quantity) {  
                    
                       this.quantity = quantity;  
                    }  
                        
                   @CreateProcess(definition="simple")  
                   
                   public  void startProcess() 
                   {        
                     processQuantity = new Long(getQuantity());  
                     System.out.println("Order: "+getQuantity());
                     
                   }  
                   
                   @StartTask  
                   @EndTask(transition="todecision")  
                        public void done() 
                        {  
                        System.out.println("done");
                        }  
                   
                   @StartTask  
                   @EndTask(transition="cancel")  
                     public void cancel() 
                        {  
                        }  
                



                • 5. Re: Using Drools for jBPM decision
                  Mas Mohktar Newbie

                  Hi,


                  Have u solve the problem yet? I'm having the same problem too. If you have solve it, could you tell me the solution?






                  turpin vincent wrote on Mar 12, 2009 09:35:


                  bonjour,

                  First thanks for answering me so fast and these few words in french. I haven't enabled debug but i'm going to and i will post then more information. For the moment i just can add that the file AccountAproval.drl is correctly parsed and the probleme seems to come from the data handler witch return null in spite of toDeliver or toEnd. If it can help i'm working from these two examples: http://docs.jboss.com/seam/latest/reference/en-US/html/drools.html (chapter 14.3) and http://www.jboss.org/community/docs/DOC-11096.

                  In addition, actually if the rule doesn't evaluate to setOutcome(toDeliver), it return null but i think that the condition in the rule is evaluated (if the syntaxe condition isn't correct i get an error about that).

                  I give my java class too (mabe it will help) i think that the problem can come from the fact taht i dont know if i have to declare again the data handler in this class or if the descrption in the process is enough.



                  package org.domain.test.session;
                  
                   import org.jboss.seam.annotations.bpm.CreateProcess;  
                   import org.jboss.seam.annotations.bpm.EndTask;  
                   import org.jboss.seam.annotations.Name;  
                   import org.jboss.seam.annotations.bpm.StartTask;  
                   import org.jboss.seam.annotations.*;  
                   import org.jboss.seam.ScopeType;  
                     
                   @Name("orderStock")   
                   public class OrderStock  
                   {  
                      
                      @Out(scope=ScopeType.BUSINESS_PROCESS, required=false)  
                      Long processQuantity;  
                        
                      public Long getProcessQuantity() {
                            return processQuantity;
                       }
                  
                       public void setProcessQuantity(Long processQuantity) {
                            this.processQuantity = processQuantity;
                       }
                  
                       private int quantity ;  
                          
                      public int getQuantity()  
                      {  
                         return quantity;  
                      }  
                     
                      public void setQuantity(int quantity) {  
                      
                         this.quantity = quantity;  
                      }  
                          
                     @CreateProcess(definition="simple")  
                     
                     public  void startProcess() 
                     {        
                       processQuantity = new Long(getQuantity());  
                       System.out.println("Order: "+getQuantity());
                       
                     }  
                     
                     @StartTask  
                     @EndTask(transition="todecision")  
                          public void done() 
                          {  
                          System.out.println("done");
                          }  
                     
                     @StartTask  
                     @EndTask(transition="cancel")  
                       public void cancel() 
                          {  
                          }  
                  






                  Click HELP for text formatting instructions. Then edit this text and check the preview.