<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I'm not very experienced with Drools but have some Java code that dynamically loads/unloads rules from a KnowledgeBase. It worked with 5.2 but now throws the following exception with 5.3<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">org.drools.RuntimeDroolsException: Unable to merge resource attribute for type declaration of class: 'NormalizedEvent'<o:p></o:p></p>
<p class="MsoNormal"> at org.drools.common.AbstractRuleBase.mergeLeft(AbstractRuleBase.java:642)<o:p></o:p></p>
<p class="MsoNormal"> at org.drools.common.AbstractRuleBase.mergeTypeDeclarations(AbstractRuleBase.java:608)<o:p></o:p></p>
<p class="MsoNormal"> at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:537)<o:p></o:p></p>
<p class="MsoNormal"> at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:458)<o:p></o:p></p>
<p class="MsoNormal"> at org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)<o:p></o:p></p>
<p class="MsoNormal"> at com.hp.mon.processor.KnowledgeSessionFactory.addRules(KnowledgeSessionFactory.java:181)<o:p></o:p></p>
<p class="MsoNormal"> at com.hp.mon.processor.RuleRunner.runRules(RuleRunner.java:54)
<o:p></o:p></p>
<p class="MsoNormal"> at com.hp.mon.processor.RulesTest.test(RulesTest.java:57)
<o:p></o:p></p>
<p class="MsoNormal"> at com.hp.mon.processor.RulesTest.testSiteScopeSNMPRules(RulesTest.java:85)<o:p></o:p></p>
<p class="MsoNormal"> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
<o:p></o:p></p>
<p class="MsoNormal"> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
<o:p></o:p></p>
<p class="MsoNormal"> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
<o:p></o:p></p>
<p class="MsoNormal"> at java.lang.reflect.Method.invoke(Unknown Source) <o:p>
</o:p></p>
<p class="MsoNormal"> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
<o:p></o:p></p>
<p class="MsoNormal"> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
<o:p></o:p></p>
<p class="MsoNormal"> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)<o:p></o:p></p>
<p class="MsoNormal"> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)<o:p></o:p></p>
<p class="MsoNormal"> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)<o:p></o:p></p>
<p class="MsoNormal"> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)<o:p></o:p></p>
<p class="MsoNormal"> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)<o:p></o:p></p>
<p class="MsoNormal"> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have three .drl files. The first is "globals.drl" that simply imports and defines some global variables (e.g, a org.slf4j.Logger, etc.). This globals.drl file also defines NormalizedEvent as follows:<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">declare NormalizedEvent <o:p></o:p></p>
<p class="MsoNormal"> @role( event ) <o:p></o:p></p>
<p class="MsoNormal">end <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The second rules file (defaultRules.drl) contains default rules for aging out old / stale events.<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">The third rules file has rules additional rules that are specific to a policy being dynamically deployed to our application.<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">The compilation and loading process treats "globals.drl" as common "header" file. That is, rules files are pre-pended with globals.drl before they are compiled. For example:<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal"> String globals = readDrlfile("globals.drl"); <o:p></o:p></p>
<p class="MsoNormal"> String newRules = readDrlfile("rulesToAdd.drl"); <o:p></o:p></p>
<p class="MsoNormal"> knowledgeBuilder.add(ResourceFactory.newReaderResource(new StringReader(globals + newRules)));<o:p></o:p></p>
<p class="MsoNormal"> if (knowledgeBuilder.hasErrors()) { <o:p></o:p></p>
<p class="MsoNormal"> throw exception ... <o:p></o:p></p>
<p class="MsoNormal"> } <o:p></o:p></p>
<p class="MsoNormal"> // No exception so compile succeeded --- BTW, it's using JANINO
<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages()); // ERROR<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">The first compile and load (globals.drl + defaultRules.drl) succeeds but I get this exception when I try to compile and load an additional file (globals.drl + additionalRules.drl).<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">This code was also written by someone not very familar with Drools but it was working in 5.2 and now I need to get it working with 5.3 Looks like there were some significant code changes to AbstractRuleBase between these two releases.<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">Any thoughts or suggestion here would be greatly appreciated.<o:p></o:p></p>
</div>
</body>
</html>