Announcement Announcement Module
No announcement yet.
Drools support Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Drools support

    I see few posts talking about drools and also on drools site about drool integeration with spring. But can't find any docs here on spring or on drools on how to user drools with spring. Can someone please help!


  • #2
    It is included in Spring Modules

    MfG Mirko


    • #3
      I used Spring Modules + Drools on a recent project. Here's the XML that made it tick:

          <!-- ============================== JSR-94 &#40;DROOLS&#41; DEFINITIONS ============================== -->
      	<bean id="ruleServiceProvider" class="org.springmodules.jsr94.factory.DefaultRuleServiceProviderFactoryBean">
      		<property name="provider"><value>http&#58;//</value></property>
      		<property name="providerClass"><value>org.drools.jsr94.rules.RuleServiceProviderImpl</value></property>
      	<bean id="ruleRuntime" class="org.springmodules.jsr94.factory.RuleRuntimeFactoryBean">
      		<property name="serviceProvider"><ref local="ruleServiceProvider"/></property>
      	<bean id="ruleAdministrator" class="org.springmodules.jsr94.factory.RuleAdministratorFactoryBean">
      		<property name="serviceProvider"><ref local="ruleServiceProvider"/></property>
      	<bean id="ruleSource" class="org.springmodules.jsr94.rulesource.DefaultRuleSource">
      		<property name="ruleRuntime"><ref local="ruleRuntime"/></property>
      		<property name="ruleAdministrator"><ref local="ruleAdministrator"/></property>
      		<property name="source"><value>classpath&#58;foo.drl</value></property>
      		<property name="bindUri"><value>foo</value></property>
      	<bean id="jsr94Template" class="org.springmodules.jsr94.core.Jsr94Template">
      		<property name="ruleSource"><ref local="ruleSource"/></property>


      • #4
        There are two versions of spring integration included with drools. In the 2.0 release there is the drools-annotation module (

        Comming in the next month, in the 2.1 release, will be a much deeper spring integration. This is the version that I currently use in our trading system. Nearly all of the development is complete and checked into the cvs head, I only have some jira issues that need to be resolved. There are examples using the drools-spring in the drools-spring-examples module. The main bulk of the remaining work is the documentation, which I am working on presently.

        Note that this spring integration is different than that of spring-modules. Drools-spring does not use jsr94 nor the drools .drl xml format. All rules are POJOs and are configured directly in the spring context files. The rule POJOs can be annoted using jdk5 (like in drools-annotation), or for pre jdk5 there are other strategies for declaring the rules, conditions, and consequences. Have a look at the HVAC example (ported from the Jess in Action book). If you have any questions, or better suggestions, feel free to ask on the drools mailing list.


        • #5
          Spring Modules + Drools configuration error

          Hi Ben,

          I'm trying to use Spring Modules + Drools, but I get this error message when I start the server:

          " class path resource [projectRules.drl] cannot be opened because it does not exist"

          My rules.xml file is identical as yours (listed in #3), I only changed the file name to mine "projectRules.drl".

          Where are your drl file located in your project? I tried, without success, to put it in my java source folder and in the WEB-INF folder.

          Any idea?



          • #6
            Can you post some directory listing? You have to put your drl file inside the classpath (WEB-INF/classes not just WEB-INF or in your bin directory).