Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration
John, All you need to do is create an account for yourself in the JIRA home page and you will be able to create the ticket and upload your project. That is the best way as it provides tracking and avoids your code being lost in someone's (or my) inbox. https://issues.jboss.org/browse/JBRULES Edson 2011/12/13 Green, John M (HP Software) > Edson, > > ** ** > > Thanks for your feedback. I've have created an eclipse/maven project to > duplicate this problem but I couldn't figure out how to open an issue in > Jira (perhaps I don't have permission). > > ** ** > > If I include all the dependent libraries in a zip file (for convenience) > the zip will be 7MB (which might not be so convenient after all). > > ** ** > > Please let me know how I can open a new issue in Jira and/or how best to > deliver this project to you. > > ** ** > > John > > *From:* rules-users-boun...@lists.jboss.org [mailto: > rules-users-boun...@lists.jboss.org] *On Behalf Of *Edson Tirelli > *Sent:* Friday, December 09, 2011 5:34 PM > *To:* Rules Users List > *Subject:* Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: > Unable to merge resource attribute for type declaration > > ** ** > > ** ** > >Looks like a bug in the merging algorithm for types. Can any of you > please open a JIRA with a small test case and/or instructions on how to > reproduce plz? > > ** ** > >Thank you, > > Edson > > On Fri, Dec 9, 2011 at 6:34 PM, jmgreen wrote: > > I was able to work around this problem by filtering out the > KnowledgePackage > containing my NormalizedEvent. In Drools 5.2.0 there was no problem > adding > this KnowledgePackage multiple times but apparently 5.3.0 doesn't cope with > it well. I'm still not sure if that is a feature or a defect in 5.3.0. > In any event doing the following make the exception go away. > > I'm still curious if this is a feature or a defect in 5.3.0. Any thoughts > or opinions regarding are welcome. > > > >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 > > Collection pkgs = > knowledgeBuilder.getKnowledgePackages(); > > > pkgs=filterOutAnyPackageThatHasNoRulesAndNameMatchingNormalizeEventPackageName(pkgs); > knowledgeBase.addKnowledgePackages(pkgs); // NO ERROR ANYMORE > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/rules-users-5-3-0-Final-throws-RuntimeDroolsException-Unable-to-merge-resource-attribute-for-type-den-tp3573815p3574420.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > ** ** > > -- > Edson Tirelli > JBoss Drools Core Development > JBoss by Red Hat @ www.jboss.com > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration
Edson, Thanks for your feedback. I've have created an eclipse/maven project to duplicate this problem but I couldn't figure out how to open an issue in Jira (perhaps I don't have permission). If I include all the dependent libraries in a zip file (for convenience) the zip will be 7MB (which might not be so convenient after all). Please let me know how I can open a new issue in Jira and/or how best to deliver this project to you. John From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli Sent: Friday, December 09, 2011 5:34 PM To: Rules Users List Subject: Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration Looks like a bug in the merging algorithm for types. Can any of you please open a JIRA with a small test case and/or instructions on how to reproduce plz? Thank you, Edson On Fri, Dec 9, 2011 at 6:34 PM, jmgreen mailto:john.gr...@hp.com>> wrote: I was able to work around this problem by filtering out the KnowledgePackage containing my NormalizedEvent. In Drools 5.2.0 there was no problem adding this KnowledgePackage multiple times but apparently 5.3.0 doesn't cope with it well. I'm still not sure if that is a feature or a defect in 5.3.0. In any event doing the following make the exception go away. I'm still curious if this is a feature or a defect in 5.3.0. Any thoughts or opinions regarding are welcome. 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 Collection pkgs = knowledgeBuilder.getKnowledgePackages(); pkgs=filterOutAnyPackageThatHasNoRulesAndNameMatchingNormalizeEventPackageName(pkgs); knowledgeBase.addKnowledgePackages(pkgs); // NO ERROR ANYMORE -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-5-3-0-Final-throws-RuntimeDroolsException-Unable-to-merge-resource-attribute-for-type-den-tp3573815p3574420.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org> https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com<http://www.jboss.com> ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration
An easy way to reproduce, as reported by jmgreen: >> file1.drl << package test; declare MyClass field : String end >> file2.drl << package test; declare MyClass @role(event) end Try creating a KB, adding file1.drl and then file2.drl -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-5-3-0-Final-throws-RuntimeDroolsException-Unable-to-merge-resource-attribute-for-type-den-tp3573815p3574794.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration
I can confirm the behavior, type declarations apparently can't be redefined in multiple resources - i.e. the AbstractRuleBase (line 642) throws an exception when merging in a package containing a redeclaration of a type coming from a different resource w.r.t. to the original type declarations. I think the intention was to prevent additional redeclarations of a bean, with all the related classloading issues. Unfortunately, this clashes with the policy that classes must be (re)declared in order to add metadata or let other beans extend them.** My suggestion would be to differentiate >>definitions<<, i.e. the first declaration of a novel bean, resulting in a class generation, from >>declarations<< (my wording), i.e. any use that does NOT result in class definition. @Edson: this is something I wanted to mention to you before, just hadn't time :) -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-5-3-0-Final-throws-RuntimeDroolsException-Unable-to-merge-resource-attribute-for-type-den-tp3573815p3574791.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration
Looks like a bug in the merging algorithm for types. Can any of you please open a JIRA with a small test case and/or instructions on how to reproduce plz? Thank you, Edson On Fri, Dec 9, 2011 at 6:34 PM, jmgreen wrote: > I was able to work around this problem by filtering out the > KnowledgePackage > containing my NormalizedEvent. In Drools 5.2.0 there was no problem > adding > this KnowledgePackage multiple times but apparently 5.3.0 doesn't cope with > it well. I'm still not sure if that is a feature or a defect in 5.3.0. > In any event doing the following make the exception go away. > > I'm still curious if this is a feature or a defect in 5.3.0. Any thoughts > or opinions regarding are welcome. > > >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 >Collection pkgs = > knowledgeBuilder.getKnowledgePackages(); > > > pkgs=filterOutAnyPackageThatHasNoRulesAndNameMatchingNormalizeEventPackageName(pkgs); > knowledgeBase.addKnowledgePackages(pkgs); // NO ERROR ANYMORE > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/rules-users-5-3-0-Final-throws-RuntimeDroolsException-Unable-to-merge-resource-attribute-for-type-den-tp3573815p3574420.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration
I was able to work around this problem by filtering out the KnowledgePackage containing my NormalizedEvent. In Drools 5.2.0 there was no problem adding this KnowledgePackage multiple times but apparently 5.3.0 doesn't cope with it well. I'm still not sure if that is a feature or a defect in 5.3.0. In any event doing the following make the exception go away. I'm still curious if this is a feature or a defect in 5.3.0. Any thoughts or opinions regarding are welcome. 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 Collection pkgs = knowledgeBuilder.getKnowledgePackages(); pkgs=filterOutAnyPackageThatHasNoRulesAndNameMatchingNormalizeEventPackageName(pkgs); knowledgeBase.addKnowledgePackages(pkgs); // NO ERROR ANYMORE -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-5-3-0-Final-throws-RuntimeDroolsException-Unable-to-merge-resource-attribute-for-type-den-tp3573815p3574420.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration
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.3Looks like there were some significant code changes to AbstractRuleBase between these two releases. Any thoughts or suggestion here would be greatly appreciated. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users