<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.&nbsp; I have a singleton which contains a hashmap to do the caching.&nbsp; I am using the Guvnor to pull my rules from.&nbsp; This works fine except when the rules change on the Guvnor.&nbsp; When the rule base tries to refresh in my application, I am getting a ClassCastException.&nbsp; Any ideas?&nbsp;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>private HashMap&lt;String, RuleBase&gt; ruleBaseMap = new HashMap&lt;String, RuleBase&gt;();</FONT></DIV>
<DIV>&nbsp;&nbsp;// check to see if we already set up this rule base</DIV>
<DIV><BR>&nbsp;&nbsp;if (ruleBaseMap.containsKey(product.getConfigurationRule())) {<BR>&nbsp;&nbsp;&nbsp;rb = ruleBaseMap.get(product.getConfigurationRule());<BR>&nbsp;&nbsp;} else {<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;InitialContext context = new InitialContext();<BR>&nbsp;&nbsp;&nbsp;&nbsp;url = (String) context.lookup("java:comp/env/rules.url");<BR>&nbsp;&nbsp;&nbsp;&nbsp;url = url + product.getConfigurationRule() + "/LATEST";<BR>&nbsp;&nbsp;&nbsp;} catch (NamingException e1) {<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;Properties config = new Properties();<BR>&nbsp;&nbsp;&nbsp;config.setProperty("newInstance", "false");<BR>&nbsp;&nbsp;&nbsp;config.setProperty("url", url);<BR>&nbsp;&nbsp;&nbsp;config.setProperty("poll", "300");<BR>&nbsp;&nbsp;&nbsp;config.setProperty("name", "Assembly");<BR>&nbsp;&nbsp;&nbsp;RuleAgent agent = RuleAgent.newRuleAgent(config);<BR>&nbsp;&nbsp;&nbsp;rb = agent.getRuleBase();&nbsp;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;ruleBaseMap.put(product.getConfigurationRule(), rb);<BR>&nbsp;&nbsp;}<BR></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>