5 Replies Latest reply on Nov 30, 2009 4:17 AM by Yasser Hawari

    Seam, JBPM and Drools

    Mas Mohktar Newbie
      Hi, can anyone help me?

      This is my scenario. I am using seam 2.1.2. I create a process in my project, in the first node, the process will call some data from the dB, pass the data to the second node. In the second node, i want to evaluate the data using Drools. This is a part of my processDefinition.xml;

      ....

              <node name="Collect Data">
                      <event type="node-enter">
                              <action expression="#{collectData.collect}"/>
                      </event>
                      <transition to="Evaluate Data"></transition>
              </node>

              <node name="Evaluate Data">
                      <event type="node-enter">
                              <action expression="#{evaluateData.evaluatStatus}"/>
                      </event>
                      <transition to="Send Email"></transition>
              </node>
      .....

      I'm having trouble in the EvaluateData, in this seam component, i want to inject the workingMemory like the code below;

      @Name("evaluateData")
      public class EvaluateData {

      @In WorkingMemory evaluationRulesWorkingMemory;
      @In Status status;
      @In Result result;

      public void evaluateStatus() throws FactException
      {

          policyPricingWorkingMemory.insert(status);
          policyPricingWorkingMemory.fireAllRules();
      }
      ....


      The error is at the @In WorkingMemory..where it will create a null value, and will create error in the JBPM context. The error will also occur if i define the workingmemory directly in processDefinition. I do not have problem injecting the data that i pass from the previous node. And the output from the .drl file is a just strings.

      This is my Drools part in the component.xml;

      ...

           <component name="evaluationRule"
              class="org.jboss.seam.drools.RuleBase">
              <property name="ruleFiles">evaluation.drl</property>
           </component>
                 <component name="evaluationRulesWorkingMemory"
              class="org.jboss.seam.drools.ManagedWorkingMemory" auto-create="true">
              <property name="ruleBase">"#{evaluationRules}"</property>
            </component>

      .........

      Another question is, where should i put my .drl file? Currently, i put it in the EAR folder.

      Thank you for your time.||||
        • 1. Re: Seam, JBPM and Drools
          Yasser Hawari Newbie

          for ur drools file, trying putting it in the same place as security.drl (you may need to change ur build.xml to copy ur drl file, not sure if ant will copy everything in the file or if it is selective!.)


          as for ur WorkingMemory object. trying using


          Component.getInstance(evaluationRulesWorkingMemory);


          in ur function. i had a similar scenario but with entityManager.


          best of luck

          • 2. Re: Seam, JBPM and Drools
            Mas Mohktar Newbie

            if tried as you suggested, now i'm getting this error;


            Caused by javax.faces.el.EvaluationException with message: javax.ejb.EJBTransactionRolledbackException: Cannot open connection

            • 3. Re: Seam, JBPM and Drools
              Yasser Hawari Newbie

              Not sure if it helps, but i noticed that i get into problems when actions are called from jbpm and i have some values injected using @In. that means check if seam is properly injecting


              @In Status status;
              @In Result result;


              before inserting the rules.


              also try adding @AutoCreate to ur EvaluateData component.


              regarding the error u sent. It is quite unclear :). what connection cannot be opened ??!

              • 4. Re: Seam, JBPM and Drools
                Mas Mohktar Newbie
                i've added the @In(create=true) for the status components and now on that part is not error. I'm getting this error now

                java.lang.ClassCastException: java.lang.String
                        at org.jboss.seam.drools.ManagedWorkingMemory.getRuleBaseFromValueBinding(ManagedWorkingMemory.java:78)
                • 5. Re: Seam, JBPM and Drools
                  Yasser Hawari Newbie

                  i am not sure if this error is generated from drools as i did not use drools before. however, class casting examples are can be traced and solved. best of luck  ;)