Drools 4.0.4 Released
by Fernando Meyer
We just released Drools v4.0.4. This is a minor release with a few
improvements on existing features and some bug fixes.
Release Notes - JBoss Drools - Version 4.0.4
We would like to really thanks all the contributors that helped on getting
this release out. From those contributing patches and docs, to those testing
and reporting bugs and providing feedback. The list is a bit long to post
all names here and I may incur in a mistake forgetting someone, so our open
public thank you to you all!
Follows the release notes.
Happy Drooling
Drools Team
Release Notes - JBoss Drools - Version 4.0.4
Bug
* [JBRULES-1243] - Pattern matching does not allow spaces
* [JBRULES-1274] - NPE when using reserved word "action" as a bound
variable, or omitting rule title
* [JBRULES-1284] - ClassCastException when using "<" constraint on field
of type java.lang.Object containing data of type java.lang.Integer
* [JBRULES-1310] - java.lang.NullPointerException at
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(
JavaConsequenceBuilder.java:54)
* [JBRULES-1311] - NPE when compiling rule consequences
* [JBRULES-1313] - NullPointerException at JavaConsequenceBuilder.java:54
on RHS for simplest of consequences
* [JBRULES-1314] - Error parsing rule that is written in a single line
* [JBRULES-1316] - Serialising Both the RuleBase and WorkingMemory
throws null pointer
* [JBRULES-1317] - Rule Execution Very Slow on Subsequent Session Using
the Same Packages
* [JBRULES-1321] - org.drools.compiler.DroolsParserException: Unknown
error while parsing.
org.drools.compiler.DroolsParserException: Unknown error while
parsing.
* [JBRULES-1325] - OutOfMemory with the use of WorkingMemoryFileLogger
* [JBRULES-1336] - Typo in RuleBaseConfiguration(ClassLoader classLoder,
Properties properties) -- the ClassLoader specified in the constructor args
is not used
* [JBRULES-1337] - 'or' with predicate/return val/inline eval with
property issue
* [JBRULES-1339] - Debugging: Breakpoints are only considered for code
with variables
* [JBRULES-1340] - JBRMS - Admin - Manage Archived Assets - Open item
icon not opening item
* [JBRULES-1348] - Incorrect hash code calculation for character
attributes in alpha hashing optimization
* [JBRULES-1354] - Duplicate parameter error while trying to use pattern
bound variables or globals in accumulate function
* [JBRULES-1364] - Drl parser 'or'
* [JBRULES-1387] - Drools doesn't build with fresh maven2 installation
and no repository
* [JBRULES-1397] - org.mvel.CompileException: variable already defined
within scope
* [JBRULES-1410] - Rules with Collect / Accumulate CEs not working
correctly when dinamically added to a rulebase
* [JBRULES-1412] - ContextEntries should have cache nulled
* [JBRULES-1413] - KnowledgeHelper should have cache reset before use.
* [JBRULES-1416] - The use of HashKey is not thread safe in
CompositeObjectSinkAdapter
Feature Request
* [JBRULES-1308] - getFactHandle with equality-based assert behavior
* [JBRULES-1349] - NotNode and Exists Improvements
* [JBRULES-1375] - remove backported concurrency classes, now that we
are jdk1.5+
* [JBRULES-1395] - Add support to modify() block in java dialect
consequences
Patch
* [JBRULES-1323] - Add caching to the Objenesis instance and move
instance to the RuleBase level
Task
* [JBRULES-1421] - Update mvel version to 1.2.21 and update mvel
templates
--
Fernando Meyer http://fmeyer.org
JBoss Rules Core Developer
fernando(a)fmeyer.org
18 years
Error creating shadow fact for object: [] when inserting Collection into working memory
by Henry Canterburry
I am having the same problem as described in this post:
http://www.nabble.com/The-effect-of-not-using-shadow-facts-tp11652637p117...
The problem is, there really was no solution mentioned. Here is my
collections class that I am asserting into working memory:
public class NamedCollection<T> extends LinkedList<T>{
public NamedCollection(String name){
super();
this.name = name;
}
public String getName(){
return name;
}
/**
*
*/
private static final long serialVersionUID = -457439174592908333L;
private String name;
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
final NamedCollection other = (NamedCollection) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
}
I get the following error when inserting this fact into memory:
org.drools.RuntimeDroolsException: Error creating shadow fact for object: []
at org.drools.reteoo.Rete$ClassObjectTypeConf.getShadow(Rete.java:628)
at org.drools.reteoo.Rete.assertObject(Rete.java:166)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:858)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:60)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:54)
at
sequitem.quanteq.ruleflow.Rule_Explode_Globals_0.consequence(Rule_Explode_Globals_0.java:15)
at
sequitem.quanteq.ruleflow.Rule_Explode_Globals_0ConsequenceInvoker.evaluate(Rule_Explode_Globals_0ConsequenceInvoker.java:22)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:462)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:424)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:50)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:24)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.testRandomMarketEntryRules(RandomMarketEntryRulesTest.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at junit.textui.TestRunner.run(TestRunner.java:77)
at junit.textui.TestRunner.run(TestRunner.java:62)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.main(RandomMarketEntryRulesTest.java:64)
Caused by: java.lang.NullPointerException
at java.util.LinkedList.clear(LinkedList.java:292)E
at
sequitem.quanteq.rules.engine.NamedCollectionShadowProxy.updateProxy(Unknown
Source)
at
sequitem.quanteq.rules.engine.NamedCollectionShadowProxy.setShadowedObject(Unknown
Source)
at org.drools.reteoo.Rete$ClassObjectTypeConf.getShadow(Rete.java:626)
... 33 more
Time: 67.75
There was 1 error:
1)
testRandomMarketEntryRules(sequitem.quanteq.rules.RandomMarketEntryRulesTest)org.drools.spi.ConsequenceException:
org.drools.RuntimeDroolsException: Error creating shadow fact for object: []
at
org.drools.base.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:14)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:553)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:462)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:424)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:50)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:24)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.testRandomMarketEntryRules(RandomMarketEntryRulesTest.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.main(RandomMarketEntryRulesTest.java:64)
Caused by: org.drools.RuntimeDroolsException: Error creating shadow fact
for object: []
at org.drools.reteoo.Rete$ClassObjectTypeConf.getShadow(Rete.java:628)
at org.drools.reteoo.Rete.assertObject(Rete.java:166)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:858)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:60)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:54)
at
sequitem.quanteq.ruleflow.Rule_Explode_Globals_0.consequence(Rule_Explode_Globals_0.java:15)
at
sequitem.quanteq.ruleflow.Rule_Explode_Globals_0ConsequenceInvoker.evaluate(Rule_Explode_Globals_0ConsequenceInvoker.java:22)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
... 23 more
Caused by: java.lang.NullPointerException
at java.util.LinkedList.clear(LinkedList.java:292)
at
sequitem.quanteq.rules.engine.NamedCollectionShadowProxy.updateProxy(Unknown
Source)
at
sequitem.quanteq.rules.engine.NamedCollectionShadowProxy.setShadowedObject(Unknown
Source)
at org.drools.reteoo.Rete$ClassObjectTypeConf.getShadow(Rete.java:626)
... 33 more
18 years
Strange property access behavior resulting in NullPointerException
by Henry Canterburry
I am using Drools 4.0.3. I have a rule that I believe should work but
causes a NullPointerException at runtime.
The rule phrased this way causes a NullPointerException:
rule "Create Order Limit"
when
CandleSeries( $instrument : instrumentSpecification )
then
insert(new OrderConstraint( $instrument ));
end
While the same rule phased like this works fine:
rule "Create Order Limit"
when
$candle : CandleSeries( )
then
insert(new OrderConstraint( $candle.getInstrumentSpecification()
));
end
Is this right? I was looking at rule example 10.27 in the Drools guide
and it's written exactly like rule #1 is.
Here is the full stack trace of the rule execution from version 1:
java.lang.NullPointerException
at
org.activequant.core.domainmodel.TimeSeries.getInstrumentSpecification(Unknown
Source)
at
org.drools.base.org.activequant.core.domainmodel.CandleSeries2216507$getInstrumentSpecification.getValue(Unknown
Source)
at
org.drools.base.ClassFieldExtractor.getValue(ClassFieldExtractor.java:127)
at org.drools.rule.Declaration.getValue(Declaration.java:197)
at
sequitem.quanteq.ruleflow.Rule_Create_Order_Limit_0ConsequenceInvoker.evaluate(Rule_Create_Order_Limit_0ConsequenceInvoker.java:17)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:462)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:424)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:50)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:24)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.testRandomMarketEntryRules(RandomMarketEntryRulesTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at junit.textui.TestRunner.run(TestRunner.java:77)
at junit.textui.TestRunner.run(TestRunner.java:62)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.main(RandomMarketEntryRulesTest.java:63)
E
Time: 36.687
There was 1 error:
1)
testRandomMarketEntryRules(sequitem.quanteq.rules.RandomMarketEntryRulesTest)org.drools.spi.ConsequenceException:
java.lang.NullPointerException
at
org.drools.base.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:14)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:553)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:462)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:424)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:50)
at
sequitem.quanteq.rules.engine.StatefulEngine.execute(StatefulEngine.java:24)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.testRandomMarketEntryRules(RandomMarketEntryRulesTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
sequitem.quanteq.rules.RandomMarketEntryRulesTest.main(RandomMarketEntryRulesTest.java:63)
Caused by: java.lang.NullPointerException
at
org.activequant.core.domainmodel.TimeSeries.getInstrumentSpecification(Unknown
Source)
at
org.drools.base.org.activequant.core.domainmodel.CandleSeries2216507$getInstrumentSpecification.getValue(Unknown
Source)
at
org.drools.base.ClassFieldExtractor.getValue(ClassFieldExtractor.java:127)
at org.drools.rule.Declaration.getValue(Declaration.java:197)
at
sequitem.quanteq.ruleflow.Rule_Create_Order_Limit_0ConsequenceInvoker.evaluate(Rule_Create_Order_Limit_0ConsequenceInvoker.java:17)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
... 23 more
18 years
StatefullSession or Stateless Session
by Blair Christie
I am new to to rules 4.03 and wondered in what cases
should a statefullSession be used and in what cases a
statelessSession be used? How do you decide?
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
18 years
Re: The "Object" field in the DSL IDE Editor
by mmquelo massi
Sorry Guys.... But I do not see what "OBJECT" stand for in the DSL Editor?
I guess is something really simple but I dunno what!!
Is there anything in the DSL component that allows the user
to refer to a fact that I asserted somewhere else?
Is "Object" something like that?
Massi
18 years
Re: Can't figure out the right syntax for this rule
by Henry Canterburry
I also tried the following rule syntax with from but without collect ( ) :
rule "Explode Globals"
ruleflow-group "Data Prep"
when
$market : Market() from request.requestObjects.values
$series : CandleSeries() from $market.candleSeries
then
insert ( $series );
insert ( $market );
end
At runtime I get an exception: org.mvel.PropertyAccessException: unable
to resolve property: values
18 years
Collect Function
by Ronald R. DiFrango
All,
I have the following rule which uses the collect function:
rule "Invalid RR Line"
salience 100
when
rrDetailLine : DetailLine(detailKeyRecNo:keyRecNo != null,
lineNumber != null )
rrHeader : ArrayList( size == 0 ) from collect(RrHeader( keyRecNo !=
detailKeyRecNo ))
then
// logger.debug("Invalid RR Line: " + rrHeader.size());
logger.debug("Invalid RR Line: " + rrDetailLine.getKeyRecNo());
logger.debug("Invalid RR Line: " + rrDetailLine.getLineNumber());
drools.halt();
end
What I am seeing is that if I only have 1 RrHeader in working memory this
rule fails. Th reason I know that there is an RrHeader object is that I
change the rule to the following:
rule "Invalid RR Line"
salience 100
when
rrDetailLine : DetailLine(detailKeyRecNo:keyRecNo != null,
lineNumber != null )
rrHeader : RrHeader( keyRecNo != detailKeyRecNo )
then
// logger.debug("Invalid RR Line: " + rrHeader.size());
logger.debug("Invalid RR Line: " + rrDetailLine.getKeyRecNo());
logger.debug("Invalid RR Line: " + rrDetailLine.getLineNumber());
drools.halt();
end
And it worked just fine.
Thoughts?
Ron
18 years
Can't figure out the right syntax for this rule
by Henry Canterburry
Hi All,
I am trying to figure out how to do a pattern match against a collection
and an array. Here is one of the domain model classes:
public class DecisionRequest extends Payload {
public void addRequestObject(String key, Object value){
this.payload.put(key, value);
}
public Object getRequestObject(String key){
return this.payload.get(key);
}
* public Map<String, Object> getRequestObjects(){
return Collections.unmodifiableMap(this.payload);
}*
}
Here is my rule code for now trying to access the values in the Map
returned by *public Map<String, Object> getRequestObjects(). As you can
see, getRequestObjects does not have a setter so it isn't recognized a a
javabean property. I have tried eval etc...*
global DecisionRequest request;
global DecisionResponse response;
rule "Explode Globals"
ruleflow-group "Data Prep"
when
$market : Market() from collect( request.requestsObjects.values
)* << property values isn't recognized? (expecting type LEFT_PARENT,
mismatched token error)
*$series : CandleSeries () from collect ( $market.candleSeries
)* << candleSeries returns a CandleSeries[] (expecting type
RIGHT_PARENT, mismatched token error)
* then
insert ( $series );
insert ( $market );
end
What would be the right way to pattern match against these values?
Thanks for any help
HC
18 years
How to write constraint about a Map inside a Map?
by Felipe Piccolini
Suppouse I have a Map attribute and one of the values is another
Map...how can I check a member of the inner Map?
class MyFact{
Map map;
public MyFact(){
this.map = new HashMap();
}
....setter and getter...
}
-- test --
MyFact myFact = new MyFact();
Map innerMap = new HashMap();
innerMap.put("innerKey", new String("InnerValue"));
Map map = new HashMap();
map.put("mapKey", innerMap);
myFact.setMap(map);
.... set the RuleBase and insert myFact as a fact for the
WorkingMemory...
-------
Now... how should I write the rule to check the innerKey ??
rule "test InnerMap"
when
$mf: MyFact( map['mapKey']['innerKey'] ==
"InnerValue" ) // doesnt work...
....
$mf: MyFact( map['mapKey'].this['innerKey'] ==
"InnerValue" ) // doesnt work...
$mf: MyFact( map['mapKey'].['innerKey'] == "InnerValue" ) //
doesnt work...
$mf: MyFact( $innerMap: map['mapKey'], $innerMap['innerKey'] ==
"InnerValue" ) // doesnt work...
$mf: MyFact( $innerMap: map['mapKey'] -> ($innerMap
['innerKey'] == "InnerValue" )) // doesnt work...
Thanks.
Felipe Piccolini M.
felipe.piccolini(a)bluesoft.cl
18 years