[rules-users] Refreshing Rule Base

Jeffrey Schneller jeffrey.schneller at envisa.com
Fri Feb 26 17:57:31 EST 2010


I posted about caching and after some more investigation it appears the problem lies in just refreshing the rulebase.
 
I created a simple package that contains 1 excel decision table which has 1 rule [row] in it.  I ran my application.  Then rebuilt the package in the Guvnor and my application refreshed the rule base correctly.
 
I have other packages which contain many 100 rules if not 1000 rules all based on multiple excel based decision tables.  If I run my application, then rebuild the package in the Guvnor, my application throws the exception.
 
RuleAgent(Assembly) EXCEPTION (Fri Feb 26 12:02:32 EST 2010): java.lang.ClassCastException: org.drools.util.ObjectHashMap cannot be cast to org.drools.reteoo.BetaMemory. Stack trace should follow.
org.drools.RuntimeDroolsException: java.lang.ClassCastException: org.drools.util.ObjectHashMap cannot be cast to org.drools.reteoo.BetaMemory

It appears the problem occurs where there are many rules.  Any ideas?
 
Thanks.
 
 

________________________________

From: rules-users-bounces at lists.jboss.org on behalf of Jeffrey Schneller
Sent: Fri 2/26/2010 12:18 PM
To: rules-users at lists.jboss.org
Subject: [rules-users] Caching RuleBase


I saw some old thread about caching the rule base on your own.  I have a singleton which contains a hashmap to do the caching.  I am using the Guvnor to pull my rules from.  This works fine except when the rules change on the Guvnor.  When the rule base tries to refresh in my application, I am getting a ClassCastException.  Any ideas? 
 
RuleAgent(Assembly) EXCEPTION (Fri Feb 26 12:02:32 EST 2010): java.lang.ClassCastException: org.drools.util.ObjectHashMap cannot be cast to org.drools.reteoo.BetaMemory. Stack trace should follow.
org.drools.RuntimeDroolsException: java.lang.ClassCastException: org.drools.util.ObjectHashMap cannot be cast to org.drools.reteoo.BetaMemory

 
My code to do the caching is below:
 
private HashMap<String, RuleBase> ruleBaseMap = new HashMap<String, RuleBase>();
  // check to see if we already set up this rule base

  if (ruleBaseMap.containsKey(product.getConfigurationRule())) {
   rb = ruleBaseMap.get(product.getConfigurationRule());
  } else {
   
   try {
    InitialContext context = new InitialContext();
    url = (String) context.lookup("java:comp/env/rules.url");
    url = url + product.getConfigurationRule() + "/LATEST";
   } catch (NamingException e1) {
   }
   
   Properties config = new Properties();
   config.setProperty("newInstance", "false");
   config.setProperty("url", url);
   config.setProperty("poll", "300");
   config.setProperty("name", "Assembly");
   RuleAgent agent = RuleAgent.newRuleAgent(config);
   rb = agent.getRuleBase(); 
   
   ruleBaseMap.put(product.getConfigurationRule(), rb);
  }

 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 6145 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20100226/1ac14001/attachment.bin 


More information about the rules-users mailing list