Re: [rules-users] Using java enums in guvnor test scenarios (6.0.1Final)
Hi, Tested this and looks like you found a bug. Made a ticket for it so we can get it fixed. https://bugzilla.redhat.com/show_bug.cgi?id=1121985 Thanks for reporting Toni Rikkola On ma, 2014-07-21 at 10:28 -0700, pacovalsera wrote: Hi all, I'm defining a test scenario within guvnor (now called kie-workbench) and I'm experiencing some issues about using java enums. The case is simple, I have a java model (deploying a jar) with a class having a member of enum type. The enum is defined in the same package but in a different java file, not an inner class. This is packed in a jar that I deploy manually uploading the file to the embedded maven repo using the workbench. / public class ClassWithMemberAsEnum { private EnumType enumMember; /*getters/setters included*/} public enum EnumType {HELLO, BYE} / Then I write a dummy rule with the guided editor like this: / import es.shin.test.ClassWithMemberAsEnum; import es.shin.test.EnumType; rule DummyRule dialect mvel when x : ClassWithMemberAsEnum( enumMember == EnumType.HELLO ) then x.setEnumMember( EnumType.BYE ); end / And finally a test scenario inserting a ClassWithMemberAsEnum initialized with enumMember=EnumType.HELLO and checking that it is changed to EnumType.BYE after firing all rules. The error message returned in the reporting console is: / EnumTest : [Error: unable to resolve method using strict-mode: java.lang.Object.es()] [Near : {... es.shin.test.EnumType.HELLO }] ^ [Line: 1, Column: 1] / I have tried the same case but defining the class in the data modeler and the enum with the enumeration editor, without using any jar artifact. The case worked as expected. Has anybody experienced the same issue? Thanks for your help. -- View this message in context: http://drools.46999.n3.nabble.com/Using-java-enums-in-guvnor-test-scenarios-6-0-1Final-tp4030411.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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using java enums in guvnor test scenarios (6.0.1Final)
Hi Toni, thanks for your quick response. As a workaround I'm defining a getter/setter for the enum member based on a string arg. That is, / public String getEnumMemberStr() {return enumMember.name();} public void setEnumMemberStr(String enumMemberStr) {enumMember=EnumType.valueOf(enumMemberStr);} / Then I use them in the test scenario to initialize facts. To avoid type errors I also define an enumeration for the new member (enumMemberStr), so the scenario editor shows a combo rather and a free text field. In the rules there is no problem in using the enum member (enumMember). Meanwhile I'll wait for the fix in the next release. -- View this message in context: http://drools.46999.n3.nabble.com/Using-java-enums-in-guvnor-test-scenarios-6-0-1Final-tp4030411p4030421.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] [drools-wb] how to move an asset to another package ?
Hello, I'm in the process of refactoring the different packages in my project. How can I move an asset (a guided decision table in this case) from its current package to a new package ? It seems there's no button or action for that in drools-wb ? Regards. --jps -- View this message in context: http://drools.46999.n3.nabble.com/drools-wb-how-to-move-an-asset-to-another-package-tp4030422.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] Drools Applications Google Group
A while back there was a discussion on the volume of posts and the range of post discussions. OptaPlanner already has it’s own google group, which has helped reduce the volume. There is still the discussion on whether to split Drools. My initial idea is to leave this list for installation, setup, configuration, deployment and getting started (hello world won’t run) - this tends to be a fairly shallow knowledge area, that new people will need to deal with. Then also create a separate google group for those wanting help on writing rule applications, that’s authoring (drl, score cards, decision tables etc) and running (insert, fireAllRules etc); this would become a deep knowledge area. In the google group you would not ask how to install the workbench, or how to deploy your app, or how to setup HA etc. Thoughts? We are about to do 6.1 final. For this we are revamping the websites, and sorting out our communications (lists etc) at the same time. Mark ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] how to count distinct nested property?
Hi, I’m trying to wrap my head around how to use a combination of accumulate from and collect from to get a count of how many unique items there are of a nested child property and run the RHS of a rule if it’s 1 So I have Many of Object A Each one contains An object B An object C Object C contains a nested child property So A +-+-B | +-C – property myId (many of these in the working memory) The rule I’m working with right now is rule B must only be at 1 myId per day when $b : B() $c : C() $aList : ArrayList (size 1) from collect( A(b == $b, c.getDate() == $c.getDate()) ) eval ( RulesUtils.countIdsForC ($aList) 1 ) then //fire some rules here end and the RulesUtils method is public static int countIdsForC (List aList) { SetInteger myIds = new HashSetInteger(); for (A a : aList) { myIds.add(a.getC().getMyId()); } return myIds.size(); } Now I’m well aware that this is sub-optimal, and indeed is firing lots of extra times and is really (Really) slow. I can vizualise that this should easily be possible with some combination of compound accumulate and collect statements, but for the life of me I can’t work out the correct arrangement (This is actually for use in an optaplanner ruleset so it will potentially be working on lots of data, over many iterations). Any suggestions on how to do this the way I know it needs to be, greatfully appreciated -- View this message in context: http://drools.46999.n3.nabble.com/how-to-count-distinct-nested-property-tp4030424.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] Dynamically loading rules in KieBase
I'm bumping this question for general interest on other possible solutions, and to give my two cents. The closest I was to getting this feature in Drools 6 from the public APIs, is to use a persistent session. Then, when I loaded an existing session, I would pass a newly created KieBase, like this KieStoreServices kstore = KieServices.Factory.get().getStoreServices(); KieBase kbase = ...; //create a Kie Base Environment env = ...; //create an environment KieSession ksession = kstore.newKieSession(kbase, null, env); Integer sessionId = ksession.getId(); KieBase kbase2 = ...; //updated Kie base KieSession ksessionReloaded = ks.loadKieSession(kbase2, null, env); ksession and ksessionReloaded would be the same working memory and agenda, but the kie base they work with would change. Hope this helps, but I hope more for an alternative -- View this message in context: http://drools.46999.n3.nabble.com/Dynamically-loading-rules-in-KieBase-tp4030351p4030425.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] how to count distinct nested property?
I wonder if something like this might do it? when $set : HashSet ( ) from accumulate ( ObjectA ( $myId : objectC.myId ), init ( HashSet uniqueIds = new HashSetString(); ), action ( uniqueIds.add($id); ), reverse ( uniqueIds.remove($id); ), result ( uniqueIds ) ) HashSet ( this == $set, size 1 ) then // consequence end - Jeremy On Tue, Jul 22, 2014 at 8:42 AM, richardhands richard.ha...@uk.sopragroup.com wrote: Hi, I’m trying to wrap my head around how to use a combination of accumulate from and collect from to get a count of how many unique items there are of a nested child property and run the RHS of a rule if it’s 1 So I have Many of Object A Each one contains An object B An object C Object C contains a nested child property So A +-+-B | +-C – property myId (many of these in the working memory) The rule I’m working with right now is rule B must only be at 1 myId per day when $b : B() $c : C() $aList : ArrayList (size 1) from collect( A(b == $b, c.getDate() == $c.getDate()) ) eval ( RulesUtils.countIdsForC ($aList) 1 ) then //fire some rules here end and the RulesUtils method is public static int countIdsForC (List aList) { SetInteger myIds = new HashSetInteger(); for (A a : aList) { myIds.add(a.getC().getMyId()); } return myIds.size(); } Now I’m well aware that this is sub-optimal, and indeed is firing lots of extra times and is really (Really) slow. I can vizualise that this should easily be possible with some combination of compound accumulate and collect statements, but for the life of me I can’t work out the correct arrangement (This is actually for use in an optaplanner ruleset so it will potentially be working on lots of data, over many iterations). Any suggestions on how to do this the way I know it needs to be, greatfully appreciated -- View this message in context: http://drools.46999.n3.nabble.com/how-to-count-distinct-nested-property-tp4030424.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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] how to count distinct nested property?
err, typo there, add() and remove() should be using $myId instead of $id On Tue, Jul 22, 2014 at 9:38 AM, Jeremy Ary jeremy@gmail.com wrote: I wonder if something like this might do it? when $set : HashSet ( ) from accumulate ( ObjectA ( $myId : objectC.myId ), init ( HashSet uniqueIds = new HashSetString(); ), action ( uniqueIds.add($id); ), reverse ( uniqueIds.remove($id); ), result ( uniqueIds ) ) HashSet ( this == $set, size 1 ) then // consequence end - Jeremy On Tue, Jul 22, 2014 at 8:42 AM, richardhands richard.ha...@uk.sopragroup.com wrote: Hi, I’m trying to wrap my head around how to use a combination of accumulate from and collect from to get a count of how many unique items there are of a nested child property and run the RHS of a rule if it’s 1 So I have Many of Object A Each one contains An object B An object C Object C contains a nested child property So A +-+-B | +-C – property myId (many of these in the working memory) The rule I’m working with right now is rule B must only be at 1 myId per day when $b : B() $c : C() $aList : ArrayList (size 1) from collect( A(b == $b, c.getDate() == $c.getDate()) ) eval ( RulesUtils.countIdsForC ($aList) 1 ) then //fire some rules here end and the RulesUtils method is public static int countIdsForC (List aList) { SetInteger myIds = new HashSetInteger(); for (A a : aList) { myIds.add(a.getC().getMyId()); } return myIds.size(); } Now I’m well aware that this is sub-optimal, and indeed is firing lots of extra times and is really (Really) slow. I can vizualise that this should easily be possible with some combination of compound accumulate and collect statements, but for the life of me I can’t work out the correct arrangement (This is actually for use in an optaplanner ruleset so it will potentially be working on lots of data, over many iterations). Any suggestions on how to do this the way I know it needs to be, greatfully appreciated -- View this message in context: http://drools.46999.n3.nabble.com/how-to-count-distinct-nested-property-tp4030424.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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] how to count distinct nested property?
My last comparison there may be problematic as well...too focused on the accumulate to see the obvious. I think that approach might still require an eval to check the size constraint on the list and we don't really want that. What you could do instead, however, is insert the hashset into the working memory in that rule's consequence and have a 2nd rule that's just HashSet ( size 1 ) and its consequence does your actions and retracts the hashset back out of memory. - J On Tue, Jul 22, 2014 at 9:39 AM, Jeremy Ary jeremy@gmail.com wrote: err, typo there, add() and remove() should be using $myId instead of $id On Tue, Jul 22, 2014 at 9:38 AM, Jeremy Ary jeremy@gmail.com wrote: I wonder if something like this might do it? when $set : HashSet ( ) from accumulate ( ObjectA ( $myId : objectC.myId ), init ( HashSet uniqueIds = new HashSetString(); ), action ( uniqueIds.add($id); ), reverse ( uniqueIds.remove($id); ), result ( uniqueIds ) ) HashSet ( this == $set, size 1 ) then // consequence end - Jeremy On Tue, Jul 22, 2014 at 8:42 AM, richardhands richard.ha...@uk.sopragroup.com wrote: Hi, I’m trying to wrap my head around how to use a combination of accumulate from and collect from to get a count of how many unique items there are of a nested child property and run the RHS of a rule if it’s 1 So I have Many of Object A Each one contains An object B An object C Object C contains a nested child property So A +-+-B | +-C – property myId (many of these in the working memory) The rule I’m working with right now is rule B must only be at 1 myId per day when $b : B() $c : C() $aList : ArrayList (size 1) from collect( A(b == $b, c.getDate() == $c.getDate()) ) eval ( RulesUtils.countIdsForC ($aList) 1 ) then //fire some rules here end and the RulesUtils method is public static int countIdsForC (List aList) { SetInteger myIds = new HashSetInteger(); for (A a : aList) { myIds.add(a.getC().getMyId()); } return myIds.size(); } Now I’m well aware that this is sub-optimal, and indeed is firing lots of extra times and is really (Really) slow. I can vizualise that this should easily be possible with some combination of compound accumulate and collect statements, but for the life of me I can’t work out the correct arrangement (This is actually for use in an optaplanner ruleset so it will potentially be working on lots of data, over many iterations). Any suggestions on how to do this the way I know it needs to be, greatfully appreciated -- View this message in context: http://drools.46999.n3.nabble.com/how-to-count-distinct-nested-property-tp4030424.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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] KieContainer#updateToVersion fails when both versions of a drl file contain an event type declaration for an existing class
Mark, thank you for the response. I was able to reproduce this issue with 6.1CR1 and the latest code from the 6.1.x as of this morning. I created a bug ticket for this issue and a pull request containing the unit test I wrote. Ticket: https://issues.jboss.org/browse/DROOLS-560 Pull request: https://github.com/droolsjbpm/drools/pull/360 -- View this message in context: http://drools.46999.n3.nabble.com/KieContainer-updateToVersion-fails-when-both-versions-of-a-drl-file-contain-an-event-type-declaratios-tp4030100p4030434.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] Are globals not permitted with queries?
I was experimenting with ways of avoiding having to put literal strings into my rules (it is very fragile and bugs can be silent for a long time). I tried declaring a global and then tried supplying it to a query. This generates a backtrace during the newKieSession. A simple example to provoke the problem: KieServices ks = KieServices.Factory.get(); KieContainer kContainer = ks.getKieClasspathContainer(); KieSession kSession = kContainer.newKieSession(ksession-rules); kSession.setGlobal(AString, Hello World); kSession.fireAllRules(); package com.sample global java.lang.String AString; declare Thing name: String @key end rule init when then insert( new Thing( AString ) ); end query test(String $in) Thing( $in; ) end rule spot when test( Hello World; ) Thing( Hello World; ) test( AString; ) Thing( AString; ) then System.out.println(found msg\n); end java.lang.NullPointerException at org.drools.core.rule.LogicTransformer.processElement(LogicTransformer.java:243) at org.drools.core.rule.LogicTransformer.processElement(LogicTransformer.java:263) at org.drools.core.rule.LogicTransformer.fixClonedDeclarations(LogicTransformer.java:134) at org.drools.core.rule.LogicTransformer.transform(LogicTransformer.java:99) at org.drools.core.definitions.rule.impl.RuleImpl.getTransformedLhs(RuleImpl.java:560) at org.drools.core.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:105) at org.drools.core.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:100) at org.drools.core.impl.KnowledgeBaseImpl.addRule(KnowledgeBaseImpl.java:1455) at org.drools.core.impl.KnowledgeBaseImpl.addRule(KnowledgeBaseImpl.java:1435) at org.drools.core.impl.KnowledgeBaseImpl.addPackages(KnowledgeBaseImpl.java:838) at org.drools.core.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:266) at org.drools.compiler.kie.builder.impl.KieContainerImpl.createKieBase(KieContainerImpl.java:412) at org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:346) at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:498) at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:469) at com.sample.DroolsTest.main(DroolsTest.java:17) The 3rd action in the spot rule causes the null exception during initialise, if it is present. Comment out just that line and no exceptions happen and behaviour is as expected. Are globals permitted in the way I am trying to use them, as a parameter to a query? Borris ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Dynamically loading rules in KieBase
You can add rules programmatically to an existing KieBase, but you have to: 1) add/replace the resource in the KieFileSystem 2) Cast the KieBuilder to InternalKieBuilder and use the incrementalBuild() method 3) Enjoy and report problems as this is a newer feature See the test suite here https://github.com/droolsjbpm/drools/blob/184765346e998430064a4935fbb358930946d82c/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java the latest tests show the use of the incremental builder Davide On 07/22/2014 04:20 PM, marianbuenosayres wrote: I'm bumping this question for general interest on other possible solutions, and to give my two cents. The closest I was to getting this feature in Drools 6 from the public APIs, is to use a persistent session. Then, when I loaded an existing session, I would pass a newly created KieBase, like this KieStoreServices kstore = KieServices.Factory.get().getStoreServices(); KieBase kbase = ...; //create a Kie Base Environment env = ...; //create an environment KieSession ksession = kstore.newKieSession(kbase, null, env); Integer sessionId = ksession.getId(); KieBase kbase2 = ...; //updated Kie base KieSession ksessionReloaded = ks.loadKieSession(kbase2, null, env); ksession and ksessionReloaded would be the same working memory and agenda, but the kie base they work with would change. Hope this helps, but I hope more for an alternative -- View this message in context: http://drools.46999.n3.nabble.com/Dynamically-loading-rules-in-KieBase-tp4030351p4030425.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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Applications Google Group
On 22/07/2014 14:27, Mark Proctor wrote: A while back there was a discussion on the volume of posts and the range of post discussions. OptaPlanner already has it’s own google group, which has helped reduce the volume. There is still the discussion on whether to split Drools. My initial idea is to leave this list for installation, setup, configuration, deployment and getting started (hello world won’t run) - this tends to be a fairly shallow knowledge area, that new people will need to deal with. Then also create a separate google group for those wanting help on writing rule applications, that’s authoring (drl, score cards, decision tables etc) and running (insert, fireAllRules etc); this would become a deep knowledge area. In the google group you would not ask how to install the workbench, or how to deploy your app, or how to setup HA etc. Thoughts? We are about to do 6.1 final. For this we are revamping the websites, and sorting out our communications (lists etc) at the same time. Mark A few thoughts for you: Partitioning the discussions as you suggest sounds sensible - minimising off-topic posts is always desirable. It should be *easy* for a user who lands on one of the groups (say via a Google search) to realise there is a better (more appropriate) group for them to post their question on - so maybe some form of standardised footer that compactly identifies the purposes of the different groups? Over time, I think you could also use the application writing group to bootstrap some form of How do I ... FAQ or tips and techniques listing. This could supplement the documentation, but be organised by developer task rather than language feature/area. Borris ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Are globals not permitted with queries?
The case may not be supported, but even then, it should be reported as a compilation error, not as a NPE I'll investigate and report back later Thanks Davide On 07/22/2014 05:48 PM, Borris wrote: I was experimenting with ways of avoiding having to put literal strings into my rules (it is very fragile and bugs can be silent for a long time). I tried declaring a global and then tried supplying it to a query. This generates a backtrace during the newKieSession. A simple example to provoke the problem: KieServices ks = KieServices.Factory.get(); KieContainer kContainer = ks.getKieClasspathContainer(); KieSession kSession = kContainer.newKieSession(ksession-rules); kSession.setGlobal(AString, Hello World); kSession.fireAllRules(); package com.sample global java.lang.String AString; declare Thing name: String @key end rule init when then insert( new Thing( AString ) ); end query test(String $in) Thing( $in; ) end rule spot when test( Hello World; ) Thing( Hello World; ) test( AString; ) Thing( AString; ) then System.out.println(found msg\n); end java.lang.NullPointerException at org.drools.core.rule.LogicTransformer.processElement(LogicTransformer.java:243) at org.drools.core.rule.LogicTransformer.processElement(LogicTransformer.java:263) at org.drools.core.rule.LogicTransformer.fixClonedDeclarations(LogicTransformer.java:134) at org.drools.core.rule.LogicTransformer.transform(LogicTransformer.java:99) at org.drools.core.definitions.rule.impl.RuleImpl.getTransformedLhs(RuleImpl.java:560) at org.drools.core.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:105) at org.drools.core.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:100) at org.drools.core.impl.KnowledgeBaseImpl.addRule(KnowledgeBaseImpl.java:1455) at org.drools.core.impl.KnowledgeBaseImpl.addRule(KnowledgeBaseImpl.java:1435) at org.drools.core.impl.KnowledgeBaseImpl.addPackages(KnowledgeBaseImpl.java:838) at org.drools.core.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:266) at org.drools.compiler.kie.builder.impl.KieContainerImpl.createKieBase(KieContainerImpl.java:412) at org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:346) at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:498) at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:469) at com.sample.DroolsTest.main(DroolsTest.java:17) The 3rd action in the spot rule causes the null exception during initialise, if it is present. Comment out just that line and no exceptions happen and behaviour is as expected. Are globals permitted in the way I am trying to use them, as a parameter to a query? Borris ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] KieContainer#updateToVersion fails when both versions of a drl file contain an event type declaration for an existing class
Hi Mike, I merged your test case and fixed the bug with this commit https://github.com/droolsjbpm/drools/commit/283ba1d94 Thanks a lot for having reported this problem, Mario -- View this message in context: http://drools.46999.n3.nabble.com/KieContainer-updateToVersion-fails-when-both-versions-of-a-drl-file-contain-an-event-type-declaratios-tp4030100p4030440.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] Defeasible: NPE: with multiple @Defeasible
Hi Davide, I've got a null pointer exception with defeasible. My test case is: package com.sample declare Fact fact: String @key end rule init when then System.out.println(inserting initial facts); insert( new Fact( one ) ); insert( new Fact( two ) ); insert( new Fact( two ) ); end rule rule1 @Defeasible enabled true when Fact( one; ) then System.out.println(one causes wibble); insertLogical( new Fact( wibble) ); end rule rule2 @Defeasible when Fact( two; ) then System.out.println(two causes wibble); insertLogical( new Fact( wibble) ); end rule rule3 @Defeater @Defeats( rule2 ) when Fact( two; ) then System.out.println(two negates wibble); insertLogical( new Fact( wibble), neg ); end The output I get is inserting initial facts one causes wibble two causes wibble two causes wibble two negates wibble two negates wibble Exception executing consequence for rule rule3 in com.sample: java.lang.NullPointerException at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1057) at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:152) at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:94) at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:964) at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1234) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1239) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1212) at com.sample.DroolsTest.main(DroolsTest.java:21) Caused by: java.lang.NullPointerException at org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSet.removeUndefeated(DefeasibleBeliefSet.java:295) at org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSet.add(DefeasibleBeliefSet.java:126) at org.drools.core.beliefsystem.jtms.JTMSBeliefSystem.insert(JTMSBeliefSystem.java:52) at org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSystem.insert(DefeasibleBeliefSystem.java:45) at org.drools.core.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:136) at org.drools.core.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:107) at org.drools.core.common.NamedEntryPoint.insert(NamedEntryPoint.java:234) at org.drools.core.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:1430) at org.drools.core.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:275) at org.drools.core.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:247) at com.sample.Rule_rule32132126114.defaultConsequence(Rule_rule32132126114.java:8) at com.sample.Rule_rule32132126114DefaultConsequenceInvokerGenerated.evaluate(Unknown Source) at com.sample.Rule_rule32132126114DefaultConsequenceInvoker.evaluate(Unknown Source) at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1046) ... 7 more I believe I am using snapshot 6.1.0.201407170510 but I suspect the precise version doesn't matter too much. In the above example, if you disable rule1 then the NPE doesn't happen. Only doing one two fact insertion in the init rule likewise means the NPE doesn't happen. I think the issue is something like rule3 does more than one defeat on rule2's scoring on wibble fact, but rule1 still has a say in the continuing existence of the wibble fact. Should I get a Jira log in and enter these well qualified bugs directly? Regards, Borris ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Applications Google Group
I’m currently setting a google group, won’t touch nabble. It allows welcome messages, sticky nodes, and if necessary moderation. Mark On 22 Jul 2014, at 18:24, Wolfgang Laun wolfgang.l...@gmail.com wrote: As long as Nabble is kept out. Stackoverflow is, at present, quite reasonable, with a high percentage of what I consider as interesting, i.e., the hard core Expert/Fusion questions. Cheers Wolfgang On 22/07/2014, Mark Proctor mproc...@codehaus.org wrote: A while back there was a discussion on the volume of posts and the range of post discussions. OptaPlanner already has it's own google group, which has helped reduce the volume. There is still the discussion on whether to split Drools. My initial idea is to leave this list for installation, setup, configuration, deployment and getting started (hello world won't run) - this tends to be a fairly shallow knowledge area, that new people will need to deal with. Then also create a separate google group for those wanting help on writing rule applications, that's authoring (drl, score cards, decision tables etc) and running (insert, fireAllRules etc); this would become a deep knowledge area. In the google group you would not ask how to install the workbench, or how to deploy your app, or how to setup HA etc. Thoughts? We are about to do 6.1 final. For this we are revamping the websites, and sorting out our communications (lists etc) at the same time. Mark ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Defeasible: NPE: with multiple @Defeasible
Stack trace shows the error: org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSet.removeUndefeated(DefeasibleBeliefSet.java:295) https://github.com/sotty/drools/blob/master/drools-core/src/main/java/org/drools/core/beliefsystem/defeasible/DefeasibleBeliefSet.java Maybe have a go fixing it yourself? And submit the fix with a unit test, as a pull request? http://docs.jboss.org/drools/release/5.6.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html Mark On 22 Jul 2014, at 20:40, Borris bor...@chaos.org.uk wrote: Hi Davide, I've got a null pointer exception with defeasible. My test case is: package com.sample declare Fact fact: String @key end rule init when then System.out.println(inserting initial facts); insert( new Fact( one ) ); insert( new Fact( two ) ); insert( new Fact( two ) ); end rule rule1 @Defeasible enabled true when Fact( one; ) then System.out.println(one causes wibble); insertLogical( new Fact( wibble) ); end rule rule2 @Defeasible when Fact( two; ) then System.out.println(two causes wibble); insertLogical( new Fact( wibble) ); end rule rule3 @Defeater @Defeats( rule2 ) when Fact( two; ) then System.out.println(two negates wibble); insertLogical( new Fact( wibble), neg ); end The output I get is inserting initial facts one causes wibble two causes wibble two causes wibble two negates wibble two negates wibble Exception executing consequence for rule rule3 in com.sample: java.lang.NullPointerException at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1057) at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:152) at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:94) at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:964) at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1234) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1239) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1212) at com.sample.DroolsTest.main(DroolsTest.java:21) Caused by: java.lang.NullPointerException at org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSet.removeUndefeated(DefeasibleBeliefSet.java:295) at org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSet.add(DefeasibleBeliefSet.java:126) at org.drools.core.beliefsystem.jtms.JTMSBeliefSystem.insert(JTMSBeliefSystem.java:52) at org.drools.core.beliefsystem.defeasible.DefeasibleBeliefSystem.insert(DefeasibleBeliefSystem.java:45) at org.drools.core.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:136) at org.drools.core.common.TruthMaintenanceSystem.addLogicalDependency(TruthMaintenanceSystem.java:107) at org.drools.core.common.NamedEntryPoint.insert(NamedEntryPoint.java:234) at org.drools.core.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:1430) at org.drools.core.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:275) at org.drools.core.base.DefaultKnowledgeHelper.insertLogical(DefaultKnowledgeHelper.java:247) at com.sample.Rule_rule32132126114.defaultConsequence(Rule_rule32132126114.java:8) at com.sample.Rule_rule32132126114DefaultConsequenceInvokerGenerated.evaluate(Unknown Source) at com.sample.Rule_rule32132126114DefaultConsequenceInvoker.evaluate(Unknown Source) at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1046) ... 7 more I believe I am using snapshot 6.1.0.201407170510 but I suspect the precise version doesn't matter too much. In the above example, if you disable rule1 then the NPE doesn't happen. Only doing one two fact insertion in the init rule likewise means the NPE doesn't happen. I think the issue is something like rule3 does more than one defeat on rule2's scoring on wibble fact, but rule1 still has a say in the continuing existence of the wibble fact. Should I get a Jira log in and enter these well qualified bugs directly? Regards, Borris ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] DROOLS-516 - Continued Memory Leak problem Drools 6.1.0.
Ack'd and queued. On 07/22/2014 11:46 PM, Kent Anderson wrote: It appears there is another condition where Drools holds onto memory indefinitely. (See https://issues.jboss.org/browse/DROOLS-516) Use case: We have a set of rules designed to detect a heartbeat, then report when/if the heartbeat stops. Problem: In the normal case of a constant heartbeat, memory is retained in the JVM, even though the fact count in working memory is 1. The following rules produce this problem. I have attached a test project that demonstrates this problem. 600K events are inserted into the stream, then the test driver waits. After 10 seconds, the absence detected rule fires. Requesting a GC via JMC has no effect. If you hit a key while the test driver is waiting, a new event will be added, which will cause the clear absence alarm rule to fire. At this point some memory is freed automatically. Requesting another GC removes all memory and the JVM is back in its (nearly) new condition. We consider this a memory leak since the events are gone from working memory and will no longer be considered in any rule evaluations, but they are still active somewhere in the JVM. packageorg.drools.example.api.kiemodulemodel import demo.Event declareEvent @role( event ) @timestamp( timestamp ) end declare Heartbeat @role( event ) @timestamp( event.timestamp ) event : Event end declare AbsenceDetected name: String end /* * This rule matches the first event * * NOTE: This stream requires the heartbeat event * to occur at least once before absence will be detected. */ ruledetect first heartbeat when $event : Event() not ( Heartbeat() ) then delete($event); insert(new Heartbeat($event)); System.out.println([DFH] Got event: + $event.getEventId()); end /* * This rule matches every event and stores only the most recent * as the heartbeat. */ rulekeep latest heartbeat when $heartbeat : Heartbeat() $event : Event() then delete($heartbeat); insert(new Heartbeat($event)); System.out.println([KLH] Got event: + $event.getEventId()); delete($event); end /* * This rule detects when a heartbeat stops for 10s */ ruledetect absence duration(10s) when $heartbeat : Heartbeat() not ( Event() ) not (AbsenceDetected() ) then delete($heartbeat); insert(new AbsenceDetected(Absence)); System.out.println([DA] Absence detected); end /* * This rule detects when the heartbeat starts again after * absence has been detected. */ ruleclear absence alarm when $heartbeat : Heartbeat() $absence : AbsenceDetected () then delete($absence); System.out.println([CAA] Heartbeat restored); end ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Including repository in a WAR file
I'm using Drools 5.3.0 I'd like to find out if the following scenario is possible: - Include the repository_export.zip file inside my application WAR file. This way, Guvnor won't be necessary. - Provide a special upload page just like Guvnor's Import/Export to upload a completely new repository_export.zip file when rules have changed. I haven't been able to find a way to read a repository_export.zip file with the current API. They only talk about drl, pkg, etc..etc but no zip files. I could potentially take the zip file, unzip it to an XML and maybe read this file?? Any ideas would be really helpful. Regards, Ilguapo -- View this message in context: http://drools.46999.n3.nabble.com/Including-repository-in-a-WAR-file-tp4030450.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