1 Reply Latest reply on Nov 14, 2009 1:35 AM by Robert Morse

    Drools (Guvnor) Cache Issue

    Robert Morse Apprentice

      Not sure if this is a Seam or Drools issue, but....
      Under Seam 2.2.0.GA, JBoss 5.1.0.GA, and Drools 5.0.1.GA and Guvnor, changes to rules within Guvnor followed by a rule build within Guvnor doesn't always get reflected back to Seam or the associated cache directory.  Sometimes adding a new rule, followed by a re-build works just fine.  Other times, it results in an application hang when the fireAllRules method is called.


      Under Seam, I've defined one rule agent as:







           <drools:rule-agent name="securityRules"
                url="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Security/LATEST"
                local-cache-dir="/usr/local/jboss/server/default/data/guvnor/cache/" poll="30"/> 
           <drools:managed-working-memory
                name="securityWorkingMemory" auto-create="true"
                rule-base="#{securityRules}" />
      
      
      






      Clearing the cache and starting up JBoss, everything works fine.  If I make a rule change in Guvnor, and rebuild the rules, I'll typically get:






      08:34:24,343 ERROR [STDERR] RuleAgent(default) INFO (Thu Oct 22 08:34:24 MDT 2009): Applying changes to the rulebase.
      08:34:24,343 ERROR [STDERR] RuleAgent(default) EXCEPTION (Thu Oct 22 08:34:24 MDT 2009): null. Stack trace should follow.
      08:34:24,343 ERROR [STDERR] java.lang.NullPointerException
      08:34:24,343 ERROR [STDERR]      at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:235)
      08:34:24,344 ERROR [STDERR]      at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:366)
      08:34:24,344 ERROR [STDERR]      at org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:712)
      08:34:24,344 ERROR [STDERR]      at org.drools.common.AbstractRuleBase.removePackage(AbstractRuleBase.java:640)
      08:34:24,344 ERROR [STDERR]      at org.drools.agent.PackageProvider.removePackage(PackageProvider.java:44)
      08:34:24,344 ERROR [STDERR]      at org.drools.agent.PackageProvider.applyChanges(PackageProvider.java:80)
      08:34:24,344 ERROR [STDERR]      at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:397)
      08:34:24,344 ERROR [STDERR]      at org.drools.agent.RuleAgent$2.run(RuleAgent.java:516)
      08:34:24,344 ERROR [STDERR]      at java.util.TimerThread.mainLoop(Timer.java:512)
      08:34:24,344 ERROR [STDERR]      at java.util.TimerThread.run(Timer.java:462)
      
      
      




      The application will hang indefinitely when calling fireAllRules().


      Restarting the server fixes the problem.   If I never rebuild the rules, or restart the server after rebuilding the rules, this problem never surfaces.
      Changing the poll value doesn't appear to alter anything.  In fact, it doesn't appear that the poll value does anything at all.  I only see the cache refresh on server restart.