ArrayIndexOutOfBounds exception when predicate parameter is varArgs
by Martin A
Hello, guys,
I've got a rule which states:
rule "quest_reach_level_1_in_any_category_accomplished"
when
$gsc : GameStateController(hasEventOccurred("eventId") &&
!hasEventOccurred("otherEventId") && hasAnyEventOccurred("param1",
"param2", "param3", "param4", "param5", "param6", "param7", "param8",
"param9", "param10", "param11", "param12"))
$response : Response()
then
... some business logic
end
which ends up with:
Caused by: org.drools.RuntimeDroolsException: Exception executing predicate
hasA
nyEventOccurred("level1_love", "level1_friendship", "level1_prosperity",
"level1
_charisma", "level1_willpower", "level1_wisdom", "level1_entertainment",
"level1
_adventure", "level1_inspiration", "level1_harmony",
"level1_lightheartedness",
"level1_confidence")
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:298)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:145)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateModifyObject(SingleObjectSinkAdapter.java:68)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:149)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateModifyObject(SingleObjectSinkAdapter.java:68)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:149)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:468)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:436)
at
org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:288)
at
org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:271)
at
org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:459)
at
org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:363)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:298)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:306)
at
org.drools.base.ModifyInterceptor.doAfter(ModifyInterceptor.java:59)
at
org.mvel2.ast.InterceptorWrapper.getReducedValueAccelerated(InterceptorWrapper.java:38)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:87)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:122)
at org.mvel2.MVEL.executeExpression(MVEL.java:930)
at
org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:105)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
... 47 more
Caused by: java.lang.RuntimeException: cannot invoke method:
hasAnyEventOccurred
at
org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.getValue(MethodAccessor.java:62)
at
org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:106)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:87)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:122)
at org.mvel2.MVEL.executeExpression(MVEL.java:930)
at
org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:100)
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:291)
... 67 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 12
at
org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.executeAll(MethodAccessor.java:148)
at
org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.getValue(MethodAccessor.java:47)
... 73 more
I'm using Drools 5.3.0.Final and it fails when it comes to evaluating the
predicate hasAnyEventOccurred(String... varArgs).
Thanks,
Martin
14 years, 3 months
Multiple conditions in a single BRL
by srinivasasanda
Hi,
Please suggest me in achieving my requirement.My requirement is.
When
Person age is equal to 25,Print 25 and return 25..else if Person age is
equal to 30,Print 30 and return 30,else if Person age is equal to 50,print
50 return 50..
How can I write these nested type of if-else statements in a single
BRL.Please suggest me.I tried by verifying docs bt couldnt find solution...
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Multiple-conditions-in-a-single-BRL-tp3...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Insert and Retract from drools server in one call?
by dunnlow
Hi. I've got a stateful session running in drools-server. A separate client
is inserting facts using a batchexecutioncommand and reading/using the
result returned from the service call. I need a stateful session because
when I insert the facts from the client, some of the rules that trigger
insert new facts. However, once those main facts are inserted, and the
relevant rules fire, the initial facts can be retracted.
Can anyone tell me the best way to do this. Basically, I'd like to do
something like an insertLogical (I suppose) to the server so that the fact
is retracted once all the rules have fired.
I realize I can get the facthandle from the result and then send another
command to retract that fact handle. However, this means two calls to the
server for every event; I'd like to make this happen in a single call.
Does anyone have any ideas?
Thanks,
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Insert-and-Retract-from-drools-server-i...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Problem with Negative Patterns and Temporal Constraints
by Weiss, Wolfgang
Hi all!
We have the problem that the following rule never fires:
rule "test-rule"
agenda-group "evaluation"
salience 100
when
$cue : AnalysisCue() from entry-point "LowLevelCueStream"
not(AnalysisCue(this after[0ms,2500ms] $cue) from entry-point "LowLevelCueStream")
then
logger.debug("... some message ..");
end
We found out that the problem is the combination of the negation with the conditional element "not" and the temporal constraint "[0ms,2500ms]". Using the temporal operator "this after $cue" without a temporal constraint works correct in its semantics.
Interestingly, when adding a constraint (cueType == 1) to the type in the negative pattern the rule begins to work. The rule would look like as follows:
rule "test-rule"
agenda-group "evaluation"
salience 100
when
$cue : AnalysisCue() from entry-point "LowLevelCueStream"
not(AnalysisCue(cueType == 1, this after[0ms,2500ms] $cue) from entry-point "LowLevelCueStream")
then
logger.debug("... some message ..");
end
unfortunately the rule then fires with a delay of 4 to 5 seconds. The second parameter of the temporal constraint influences the delay.
When changing the first parameter of the temporal constraint to a value greater than 0 the rule works as expected! The constraint would then look like as follows: "[1ms, 2500ms]". Whereas in our case, we want to evaluate the time window from 0 - 2500ms.
Our system works in the stream mode and we could reproduce this behaviour with the versions 5.3.1 and 5.4.0 Beta 1.
Can anybody confirm if this is a bug in Drools, or did I overlook here something?
Best regards,
Wolfgang Weiss
14 years, 3 months
Large number of rules in Drools
by Shweta1986
Hi,
I am using drools for 2 of our projects. For one of them I have
more than 20K simple rules. But with number of rules I have started seeing
out of memory exceptions and also configuring 20K rules through guvnor is
difficult. Is there an alternative for this? Is there something like file
upload for drl on guvnor ? Is there a limit on number of rules ?
Thanks,
Shweta
--
View this message in context: http://drools.46999.n3.nabble.com/Large-number-of-rules-in-Drools-tp36303...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Re: [rules-users] Using Drools Planner for dynamic service composition
by ge0ffrey
johan.kumps wrote
>
> Hi,
>
> Could you point me to a document providing some more information on this.
> Using the Drools Planner documentation alone I'm not able to find a design
> for my problem.
>
> Kind regards,
>
This problem, "the most optimal service composition achieving a certain
consumer goal" probably falls into the category of problems called "assembly
line optimization". An example of assembly line optimization is in a
furniture factory: manufacture a number of chairs and tables and order the
usage of the machines (sequentially and in parallel) as optimal as possible.
There is no public canonical example of "assembly line optimization" yet,
but Drools Planner has been successfully used for it already, for example by
ualtin (irc). The trick is to create/remove machine assignments in Move's
(something the other examples don't do). You can reuse the local search
algorithms, such as Tabu Search, but the construction heuristics might be a
problem, in which case you 'll need to write a custom SolutionInitializer
like in some examples (until the construction heuristics become more
flexible).
--
View this message in context: http://drools.46999.n3.nabble.com/Using-Drools-Planner-for-dynamic-servic...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Application Guvnor integration
by Senthil K
Hi,
I am trying to do integration between application and guvnor. I am unable to
build knowledge base using the change_set provided for the package in
Guvnor. Following is the snipet of code i am using. When i try to print
number of packages from knowledgebase, it shows 0.
Can you help me please.
System.out.println("Before rule engine start ");
String
urlstr="http://192.168.2.247:8080/guvnor-5.3.0.Final-jboss-as-5.1/org.drools.guvn...";
URL url = new URL(urlstr);
KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.newInstance", "false");
_kagent = KnowledgeAgentFactory.newKnowledgeAgent( "MyAgent",aconf );
System.out.println("after creating kagent");
_kagent.applyChangeSet(ResourceFactory.newUrlResource(url));
System.out.println("after apply change set");
ResourceChangeScannerConfiguration sconf=
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "30");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
System.out.println("After starting Notification service");
_kagent.applyChangeSet(ResourceFactory.newUrlResource(url));
_kbase = _kagent.getKnowledgeBase();
Collection<KnowledgePackage> kpackages =
_kbase.getKnowledgePackages();
System.out.println("no of packages"+kpackages.size());
--
View this message in context: http://drools.46999.n3.nabble.com/Application-Guvnor-integration-tp365592...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months