Announcement Announcement Module

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions ( project, this forum has been decommissioned in favour of Spring Extensions one at:

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Costin Leau
SpringSource - Spring Training, Consulting, and Support - "From the Source"
See more
See less
Jsr94 and JBoss Rules using DSL Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jsr94 and JBoss Rules using DSL

    I'm using the Spring Modules 0.8 release to integrate JBoss Rules via the JSR94 classes. Everything was surprisingly simple to get wired together and working, but now I am faced with an issue using DSL files. I was able to successfully load a drl file without any issues, but now I want to load both the drl and a dsl. Looking at some of the sample classes provided with the drools examples I need to pass both these files off to the PackageBuilder via an overloaded method, addPackageFromDrl.

    builder.addPackageFromDrl( drl, dsl );
    How can I do this via the Spring module classes?

    Thanks for the help...

  • #2
    After stepping through the code a bit I learned that the Spring class
    LocalRuleExecutionSetProviderImpl is looking for the key dsl in the properties
    object that is passed in and that it expects the value object in the hash table
    to be either a or a String object containing the contents of the
    dsl file. So I modified my configuration to pass in an instance of Reader for
    the dsl file.

    So I created a simple class, ReasourceAsReader, that is a FactoryBean that converts a Resource to a I then assigned this bean to the hashtable that is passed into the DefaultRuleSource as follows:

      <bean id="ruleSource" class="org.springmodules.jsr94.rulesource.DefaultRuleSource">
        <property name="ruleRuntime">
          <ref local="ruleRuntime" />
        <property name="ruleAdministrator">
          <ref local="ruleAdministrator" />
        <property name="source">
        <property name="bindUri">
        <property name="rulesetProperties">
          <map key-type="java.lang.String" value-type="java.lang.String">      
            <entry key="dsl"> 
              <bean class="">
                <property name="source">
    The code for the FactoryBean is as follows:
    import org.springframework.beans.factory.FactoryBean;
    import org.springframework.beans.factory.InitializingBean;
    public class ResourceReader implements FactoryBean, InitializingBean {
      private Resource source = null;
      private reader = null;
      public void setSource(Resource source) {
        this.source = source;
      public void afterPropertiesSet() throws Exception {
        if(source == null) {
          throw new IllegalArgumentException("Resource cannot be null!");
        EncodedResource er = new EncodedResource(source);
        reader = er.getReader();
      public Object getObject() throws Exception {
        return reader;
      public Class getObjectType() {
      public boolean isSingleton() {
        return true;
    Now the dsl file is loaded but I'm receiving the following exception:
    Caused by: 
     <at> 993028org.drools.lang.ExpanderException
     <at> 128b33aorg.drools.lang.ExpanderException
     <at> 10ea988org.drools.lang.ExpanderException
     <at> 19c4844org.drools.lang.ExpanderException
     <at> 14c8f24org.drools.lang.ExpanderException
     <at> 1498526org.drools.lang.ExpanderException
     <at> 1c4a760org.drools.lang.ExpanderException
     <at> 1c8ce14org.drools.lang.ExpanderException
     <at> 51b326org.drools.lang.ExpanderException
     <at> 1c8997eorg.drools.lang.ExpanderException
     <at> d54d3forg.drools.lang.ExpanderException
     <at> 1c26386org.drools.lang.ExpanderException
     <at> 1140cf6org.drools.lang.ExpanderException
     <at> 15efa6aorg.drools.lang.ExpanderException
     <at> 8a750aorg.drools.lang.ExpanderException
     <at> 9e6e0org.drools.lang.ExpanderException <at> 14b389
    	at org.drools.rule.Package.checkValidity(
    Any ideas as to what might be causing this?

    Thanks for the help...


    • #3
      I came accross the same problem as you are having and after some debugging, it seems like a bug in Drools. The problem is that drools does not output the exceptions correctly when the error is an ExpanderException. It seems that this is because they forgot to implement toString() on that class.

      To work around this and see the errors, set a breakpoint on the toString() method of PackageBuilderErrors. Via debugging you should then be able to navigate through an array of DroolsError objects and call getMessage() on each one to see the error message.


      • #4
        Nice solution


        We just got the same problem and your suggestion works!
        Thx cmathrusse.


        • #5
          I don't even remember having this problem But I'm glad I could be of help