<HTML dir=ltr><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.6001.18385" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#000000 size=2>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? </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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.<BR>org.drools.RuntimeDroolsException: java.lang.ClassCastException: org.drools.util.ObjectHashMap cannot be cast to org.drools.reteoo.BetaMemory<BR></FONT></DIV>
<DIV><FONT face=Arial color=#000000 size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#000000 size=2>My code to do the caching is below:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>private HashMap<String, RuleBase> ruleBaseMap = new HashMap<String, RuleBase>();</FONT></DIV>
<DIV> // check to see if we already set up this rule base</DIV>
<DIV><BR> if (ruleBaseMap.containsKey(product.getConfigurationRule())) {<BR> rb = ruleBaseMap.get(product.getConfigurationRule());<BR> } else {<BR> <BR> try {<BR> InitialContext context = new InitialContext();<BR> url = (String) context.lookup("java:comp/env/rules.url");<BR> url = url + product.getConfigurationRule() + "/LATEST";<BR> } catch (NamingException e1) {<BR> }<BR> <BR> Properties config = new Properties();<BR> config.setProperty("newInstance", "false");<BR> config.setProperty("url", url);<BR> config.setProperty("poll", "300");<BR> config.setProperty("name", "Assembly");<BR> RuleAgent agent = RuleAgent.newRuleAgent(config);<BR> rb = agent.getRuleBase(); <BR> <BR> ruleBaseMap.put(product.getConfigurationRule(), rb);<BR> }<BR></DIV>
<DIV> </DIV></BODY></HTML>