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

org.drools.RuntimeDroolsException: Unable to merge resource attribute for type declaration of class: 'NormalizedEvent'

        at org.drools.common.AbstractRuleBase.mergeLeft(AbstractRuleBase.java:642)

        at org.drools.common.AbstractRuleBase.mergeTypeDeclarations(AbstractRuleBase.java:608)

        at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:537)

        at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:458)

        at org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)

        at com.hp.mon.processor.KnowledgeSessionFactory.addRules(KnowledgeSessionFactory.java:181)

        at com.hp.mon.processor.RuleRunner.runRules(RuleRunner.java:54)

        at com.hp.mon.processor.RulesTest.test(RulesTest.java:57)

        at com.hp.mon.processor.RulesTest.testSiteScopeSNMPRules(RulesTest.java:85)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

        at java.lang.reflect.Method.invoke(Unknown Source)

        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)

        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)

        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)

        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)

        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)

        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

 

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:

declare NormalizedEvent

    @role( event )

end

 

The second rules file (defaultRules.drl) contains default rules for aging out old / stale events.

The third rules file has rules additional rules that are specific to a policy being dynamically deployed to our application.

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:

    String globals = readDrlfile("globals.drl");

    String newRules = readDrlfile("rulesToAdd.drl");

    knowledgeBuilder.add(ResourceFactory.newReaderResource(new StringReader(globals + newRules)));

     if (knowledgeBuilder.hasErrors()) {

        throw exception ...

    }

    // No exception so compile succeeded --- BTW, it's using JANINO

  

    knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());  // ERROR

    

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).

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.

Any thoughts or suggestion here would be greatly appreciated.