[rules-dev] How to Ruleflow ForEach component?

ateist ateist8 at mail.ru
Thu Apr 22 17:22:46 EDT 2010


Hi all!

I need to apply rules to each element of a collection. So I tried to use
ForEach component in my ruleflow. Here is my rule flow file 
http://n3.nabble.com/forum/FileDownload.jtp?type=n&id=744264&name=testRuleflow.rf
testRuleflow.rf .

I set CollectionExpression to "children" and VariableName to "child"
properties of the component.

In the code to run rules:

....
Map variables = new HashMap();
variables.put("children", collection);
ksession.startProcess(ruleFlowName, variables);
ksession.fireAllRules();
....

But when I run the code it throws the following exception:

437 [main] INFO com.test.TestForEach  - Start process: flow
Exception in thread "main" java.lang.IllegalArgumentException: Could not
find collection children
	at
org.drools.workflow.instance.node.ForEachNodeInstance$ForEachSplitNodeInstance.evaluateCollectionExpression(ForEachNodeInstance.java:112)
	at
org.drools.workflow.instance.node.ForEachNodeInstance$ForEachSplitNodeInstance.internalTrigger(ForEachNodeInstance.java:81)
	at
org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:112)
	at
org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:148)
	at
org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:135)
....

Any guesses what I am doing wrong?   
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-Ruleflow-ForEach-component-tp744264p744264.html
Sent from the Drools - Dev mailing list archive at Nabble.com.


More information about the rules-dev mailing list