4 Replies Latest reply on Nov 11, 2009 4:38 PM by Mas Mohktar

    Couple of new features in seam-drools integration

    Tihomir Surdilovic Master

      We added a couple of new features to the seam-drools integration:

      1. Support for Decision Tables (JBSEAM-4188):

      <drools:rule-base name="ruleBase" rule-files="myDecisionTable.xls"/>

      You can now compile rules from your Decision Table (xls) when using the drools:rule-base component in components.xml

      2. Support for Drools Custom Consequence Exception Handlers (JBSEAM-4049):

      <drools:rule-base name="ruleBase" rule-files="myDecisionTable.xls" consequence-exception-handler="#{myConsequenceExceptionHandler}"/>

      You can use the new consequence-exception-handler attribute to add a new exception handler. This exception handler can be a Seam component and can look like:

      public class MyConsequenceExceptionHandler implements ConsequenceExceptionHandler, Externalizable {
         public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         public void writeExternal(ObjectOutput out) throws IOException {
         public void handleException(Activation activation,
                                     WorkingMemory workingMemory,
                                     Exception exception) {
             throw new ConsequenceException( exception,
                                             activation.getRule() );

      3. Support for Drools Event Listeners (JBSEAM-4225):

      <drools:managed-working-memory name="workingMemory" rule-base="#{ruleBase}">

      This allows you to be notified of rule engine events, including rules firing, objects being asserted, etc by simply adding the drools:event-listeners element to your managed-working-memory component in components.xml as shown in the example

      These updates will be available in 2.2.0.CR1. We are also working on adding RuleFlow support in the near future.

        • 1. Re: Couple of new features in seam-drools integration
          Gilson Tavares Newbie

          I believe this link to thread in the rule-dev mail list gives further information about Seam / Drools integration and offers a way to send comments and suggestions on this subject (JBSEAM-4260):

          • 2. Re: Couple of new features in seam-drools integration
            Mas Mohktar Newbie

            Hi, could you please help me,

            i try to inject the working memory in the Seam component


            WorkingMemory decisionWM

            but when i run the server, i got error.

            Please help me. thank you

            • 3. Re: Couple of new features in seam-drools integration
              Tihomir Surdilovic Master

              Hello Mas,

              What is the Seam version used? Post your entire error and your components.xml so we can try to help.


              • 4. Re: Couple of new features in seam-drools integration
                Mas Mohktar Newbie
                Hi Tihomir,

                Sorry for my late reply. Ok, 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="#{notifyPatient.notification}"/>
                                <transition to="Evaluate Data"></transition>

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

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

                public class EvaluateData {

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

                public void evaluateStatus() throws FactException


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


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

                Thank you for your time.