Re: [rules-users] Searching for an object in a list inside a map
Hi! You could try something like this. I'm not 100% sure that this works: $player : Player(name == John) $roster : TeamRoster($teams : teams, $teams.get(Dodgers) contains $player) -Jarkko -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Searching-for-an-object-in-a-list-inside-a-map-tp4030156p4030164.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] NullPointerException with factType.get(fact, fieldname)
Manstis was right, I was trying to access Java class with the API for accessing declared (DRL) types. ValidationError class was created with Drools Workbench data modeller. I thought that data modeller creates declarative classes, like in Drools Guvnor. I imported ValidationError as normal Java class and and started to use as it as normal Java class and problem was solved. Sorry for all the trouble and thanks for help! -Jarkko -- View this message in context: http://drools.46999.n3.nabble.com/NullPointerException-with-factType-get-fact-fieldname-tp4028688p4028753.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] NullPointerException with factType.get(fact, fieldname)
I have this problem also with drools versions 6.0.1.FINAL and 6.1.0.Beta1 org.kie.api.definition.type.FactType.get(Object bean, String field) gives NullPointerException with default KieBase KieContainer kContainer = kieServices.newKieContainer(kieServices.newReleaseId(com.test, validationrules, 1.0-SNAPSHOT)); KieBase kbase = kContainer.getKieBase(); -Jarkko -- View this message in context: http://drools.46999.n3.nabble.com/NullPointerException-with-factType-get-fact-fieldname-tp4028688p4028731.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] NullPointerException with factType.get(fact, fieldname)
Drools version 6.0.0.FINAL I create rule package in Drools workbench and use default knowledgebase and session: KieServices kieServices = KieServices.Factory.get(); KieContainer kContainer = kieServices.newKieContainer(kieServices.newReleaseId(com.test, validationrules, 1.0-SNAPSHOT)); KieBase kbase = kContainer.getKieBase(); KieSession ksession = kContainer.newKieSession(); I have a query that returns ValidationError: query getValidationErrors validationError: ValidationError() end ValidationError is returned and it has values in its fields, but when i try to read fields of that ValidationError fact, i get NullPointerException public class DroolsValidationMessage { private FactType factType; private Object fact; public DroolsValidationMessage(KieBase kbase, Object fact) { this.fact = fact; factType = kbase.getFactType(fact.getClass().getPackage().getName(), fact.getClass().getSimpleName()); } public String getSeverity() { return (String) factType.get(fact, severity); // -- java.lang.NullPointerException } public String getDescription() { return (String) factType.get(fact, description); } } factType looks like this: ClassDefinition{className='null', superClass='java.lang.Object', interfaces=[], definedClass=class com.test.validationrules.ValidationError, traitable=null, abstract=false, fields={description=FieldDefinition{name='description', type='java.lang.String', key=false, inherited=false, index=0, initExpr='null', annotations=null, accessor=null}, severity=FieldDefinition{name='severity', type='java.lang.String', key=false, inherited=false, index=1, initExpr='null', annotations=null, accessor=null} This works if the rules and declared class is in resources folder and kmodule.xml is used. KieServices kieServices = KieServices.Factory.get(); KieContainer kContainer = kieServices.getKieClasspathContainer(); KieBase kbase = kContainer.getKieBase(kbase); KieSession ksession = kContainer.newKieSession(ksession); factType looks like this: ClassDefinition{className='com.test.validationrules.ValidationError', superClass='java.lang.Object', interfaces=[java.io.Serializable], definedClass=class com.test.validationrules.ValidationError, traitable=NONE, abstract=false, fields={description=FieldDefinition{name='description', type='java.lang.String', key=false, inherited=false, index=0, initExpr='null', annotations=null, accessor=[ClassFieldExtractor class=com.test.validationrules.ValidationError field=description]}, severity=FieldDefinition{name='severity', type='java.lang.String', key=false, inherited=false, index=1, initExpr='null', annotations=null, accessor=[ClassFieldExtractor class=com.test.validationrules.ValidationError field=severity]} -Jarkko -- View this message in context: http://drools.46999.n3.nabble.com/NullPointerException-with-factType-get-fact-fieldname-tp4028688.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 6.0.1: GC overhead limit exceeded, even though objects are retracted
We have a program that validates large amount of data. When changing this program to use drools 6.0.1 instead of 5.5.0, this GC overhead limit exceeded problem occurred. Program reads one object to memory, then validate it and then retract it. This is repeated thousands of times. java version 1.7.0_45 java options: JVM_ARGS=$JVM_ARGS -Xmx256m JVM_ARGS=$JVM_ARGS -XX:+HeapDumpOnOutOfMemoryError JVM_ARGS=$JVM_ARGS -XX:HeapDumpPath=/home/heapdumps I also tried different java garbage collection options: -XX:+UseSerialGC, -XX:+UseParallelGC and -XX:+UseConcMarkSweepGC, but it did not help. Heapdump says that: One instance of org.drools.core.reteoo.JoinNodeLeftTuple loaded by sun.misc.Launcher$AppClassLoader @ 0xf03a13a8 occupies 203,920,080 (98.40%) bytes. This error is reproduced with rules below. These rules add one object to memory, then there is one rule that evaluates that object, and after that the object is retracted. This is repeated in continuous loop, but memory runs out soon. package com.cat declare ValidationError jee : String end declare cat2 name : String age : Integer end rule 'add cat2' dialect 'mvel' salience 3000 when not(exists(cat2())) then System.out.println(insert cat2); $p = new cat2() insert ($p); modify ($p){ name = mau }; end rule 'this rule does not fire' dialect 'mvel' salience 4500 when $k1 : cat2($name : name != miau) $k2 : cat2($nameofcat2 : name == miau) then modify ($k1){ name = $nameofcat2 }; modify ($k2){ name = (miau) }; System.out.println(this rule does not fire); end rule 'retract cat2' dialect 'mvel' salience -50 when $c2 : cat2() then retract($c2); System.out.println(retract cat2); end query getValidationErrors validationError: ValidationError() end -- View this message in context: http://drools.46999.n3.nabble.com/Drools-6-0-1-GC-overhead-limit-exceeded-even-though-objects-are-retracted-tp4027803.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