1 Reply Latest reply on Jul 21, 2006 1:27 PM by gavin.king

    Drools domain specific language files in Seam

    joff

      I've managed to deploy JBoss Rules using Seam quite happily, going along with the docs, but as soon as I try and use a Domain Specific Langage file (.dsl) things come apart:

      My components.xml has this:

      <component name="myRules"
       class="org.jboss.seam.drools.RuleBase">
       <property name="ruleFiles">drools/myrules.drl</property>
      </component>
      <component name="myWorkingMemory"
       class="org.jboss.seam.drools.ManagedWorkingMemory">
       <property name="ruleBaseName">myRules</property>
      </component>


      I deploy my application EAR with both files (myrules.drl and myrules.dsl) inside the drools dir, i.e. application.ear/drools/

      The myrules.drl defines the DSL thus:
      package com.example.myapp
      
      expander myrules.dsl
      
      rule "My Rule"
      ... etc etc


      It works fine in Eclipse, but when I try and use it in my app:
      public class MyActionImpl implements MyAction {
      
      @In(create=true)
      WorkingMemory myWorkingMemory;
      
      public void doAction() {
      ....
      myWorkingMemory.assertObject(myObject);
      myWorkingMemory.fireAllRules();
      ....
      }


      I get the following exception:
      java.lang.IllegalArgumentException: Unable to use expander. Make sure a expander or dsl config is being passed to the parser. [ExpanderResolver was not set].
      
       at org.drools.lang.RuleParser.expander(Unknown Source)
      
       at org.drools.lang.RuleParser.prolog(Unknown Source)
      
       at org.drools.lang.RuleParser.compilation_unit(Unknown Source)
      
       at org.drools.compiler.DrlParser.compile(Unknown Source)
      
       at org.drools.compiler.DrlParser.parse(Unknown Source)
      
       at org.drools.compiler.DrlParser.parse(Unknown Source)
      
       at org.jboss.seam.drools.RuleBase.compileRuleBase(RuleBase.java:38)
      
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
       at java.lang.reflect.Method.invoke(Method.java:585)
      
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:16)
      
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:35)
      
       at org.jboss.seam.Component.callComponentMethod(Component.java:1418)
      
       at org.jboss.seam.Component.callCreateMethod(Component.java:1406)
      
       at org.jboss.seam.Component.newInstance(Component.java:1396)
      
       at org.jboss.seam.Component.getInstance(Component.java:1311)
      
       at org.jboss.seam.Component.getInstance(Component.java:1294)

      etc

      Do I need to be including the .dsl file somehow in the components.xml ? Or does this just not work at this stage?