function call
by hypnosat7
Hi,
I have a simple rule :
function String isTrue() {
return "true";
}
rule "new rule"
dialect "mvel"
when
eval(true)
then
System.out.println("passe"+isTrue());
end
But it seems impossible to call function's :
org.mvel.PropertyAccessException: failed to access property:
<<System.out.println("passe"+isTrue())>> in: null
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:137)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96)
at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
at org.mvel.MVEL.executeDebugger(MVEL.java:327)
at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:43)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:37)
Caused by: org.mvel.PropertyAccessException: null pointer exception in
property: isTrue()
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:143)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96)
at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)
at
org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:421)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109)
... 10 more
Caused by: java.lang.NullPointerException
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:429)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109)
... 17 more
org.drools.spi.ConsequenceException: org.mvel.PropertyAccessException:
failed to access property: <<System.out.println("passe"+isTrue())>> in: null
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:549)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:37)
Caused by: org.mvel.PropertyAccessException: failed to access property:
<<System.out.println("passe"+isTrue())>> in: null
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:137)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96)
at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
at org.mvel.MVEL.executeDebugger(MVEL.java:327)
at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:43)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
... 4 more
Caused by: org.mvel.PropertyAccessException: null pointer exception in
property: isTrue()
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:143)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96)
at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)
at
org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:421)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109)
... 10 more
Caused by: java.lang.NullPointerException
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:429)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109)
... 17 more
--
View this message in context: http://www.nabble.com/function-call-tf4346267.html#a12382405
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 3 months
Out of memory problem
by Eymeric VIEUILLE
Hi !
I am currently leading a study that compares BRMS. The aim of this study
is to determine if a rules engine can be used for our application and
what rules engine to use.
I made a prototype and I encountered a big problem of memory : no more
than 53 objects could be passed as facts. After this threshold, I
encountered a java.lang.OutOfMemoryException :
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
I increased the memory allocated to the JVM, but the more I insert
objects as Facts and the more Drools becomes slower !
I think that the problem is exactly the same as the following one :
http://lists.jboss.org/pipermail/rules-users/2007-August/002592.html
Can you confirm to me that is the same problem ? And in a positive
affirmation, how to solve this problem ? And how much time would it take ?
I am using drools 4.0 (developing whith associated eclipse IDE).
I realized a dslr that looks like this :
package com.sample
import XXX.Message;
import XXX.MyObject;
expander leg_recognizer.dsl
rule "rule 1"
no-loop true
when
$m1 is an "OUT" marker
$m2 is an "OFF" marker
$m3 is an "ON" marker
$m4 is an "IN" marker
$m4 event date is more than $m1 event date
then
print "Rule 1"
display message $m1
display message $m2
display message $m3
display message $m4
make $m1 treated
make $m2 treated
make $m3 treated
make $m4 treated
create a object "1" with state "active";
end
rule "rule 2".............(same principle) --> 6 rules in the real file.
And it uses the following dsl file :
[condition][]{message} is an "{state}" marker={message} : Message(type
== "{state}")
[consequence][]print "{string}"=System.out.println("{string}");
[consequence][]display message {object}=System.out.println("Message : "
+ {object});
[consequence][]create a object "{id}" with state "{state}"=insert(new
MyObject("{id}", "{state}"));
[consequence][]make {message} treated=retract({message});
[condition][]{message1} event date is more than {message2} event
date=eval({message1}.isALaterEventThanMessage({message2}))
Did I made a mistake in the use of Drools or is this a bug ?
Thanks for answers...That's quite urgent !
17 years, 3 months
DSL Troubles
by Andreas Boehm
Hi all,
I'm using JBoss Rules 4.0.0.12865MR3 and trying to use a DSL expander in my
DRL file:
package docmap.logic
import docmap.facts.*
expander test_expander.dsl
I didn't forget to also initialize the PackageBuilder:
builder.addPackageFromDrl(sourceReader, dslReader)
At runtime I always get the following exception, no matter which content the
DSL file has:
org.drools.rule.InvalidRulePackage:
org.drools.lang.ExpanderException@10f3a9corg.drools............
........................................ <many more ExpanderExceptions>
org.drools.lang.ExpanderException@1c9313borg.drools.lang.ExpanderException(a)1bf3519
at org.drools.rule.Package.checkValidity(Package.java:409)
Thanks in advance for any hint,
Andreas
17 years, 3 months
I can use RuleAgent without .properties file ???
by Edgardo
Hi list, I need your help, I need deploy the rules like Web Service, for
this, I develop a web service method using the RuleAgent, but the Web
Service can't read the .properties file. The question is: Exist any form
for initialize RuleAgent without .properties file???
PD1: The problem could be the tomcat, but I am desperate
PD2: Sorry for my poor English
Thanks :D
--
Edgardo Ibañez O.
17 years, 3 months
Decision Tables
by Hehl, Thomas
I'm having trouble figuring out the ACTION section of a decision table.
Everything else appears to be working.
My rules result in a simple True/False condition. To do this in a decision
table, I've created a class called BooleanAnswer that looks like:
public class BooleanAnswer {
private boolean answer;
/**
* no-arg constructor
*/
public BooleanAnswer(){
}
/**
* create your own default answer
* @param answer the answer to set
*/
public BooleanAnswer(boolean answer){
setAnswer(answer);
}
/**
* @return the answer
*/
public boolean isTrue() {
return answer;
}
/**
* @param answer the answer to set
*/
public void setAnswer(boolean answer) {
this.answer = answer;
}
}
Then I create a decision table with the following ACTION in it:
ACTION
answer: BooleanAnswer
answer.setAnswer($param);
Allowed
TRUE
This generates the following errors:
...
Caused by: org.drools.rule.InvalidRulePackage: Rule Compilation error :
[Rule name=postponePart_15, agendaGroup=MAIN, salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_15_0.java (8:343)
: The field BooleanAnswer.answer is not visible
Rule Compilation error : [Rule name=postponePart_13, agendaGroup=MAIN,
salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_13_0.java (8:343)
: The field BooleanAnswer.answer is not visible
Rule Compilation error : [Rule name=postponePart_14, agendaGroup=MAIN,
salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_14_0.java (8:343)
: The field BooleanAnswer.answer is not visible
Rule Compilation error : [Rule name=postponePart_16, agendaGroup=MAIN,
salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_16_0.java (8:343)
: The field BooleanAnswer.answer is not visible
Rule Compilation error : [Rule name=postponePart_17, agendaGroup=MAIN,
salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_17_0.java (8:343)
: The field BooleanAnswer.answer is not visible
Rule Compilation error : [Rule name=postponePart_10, agendaGroup=MAIN,
salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_10_0.java (8:343)
: The field BooleanAnswer.answer is not visible
Rule Compilation error : [Rule name=postponePart_11, agendaGroup=MAIN,
salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_11_0.java (8:343)
: The field BooleanAnswer.answer is not visible
Rule Compilation error : [Rule name=postponePart_18, agendaGroup=MAIN,
salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_18_0.java (8:343)
: The field BooleanAnswer.answer is not visible
Rule Compilation error : [Rule name=postponePart_19, agendaGroup=MAIN,
salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_19_0.java (8:343)
: The field BooleanAnswer.answer is not visible
Rule Compilation error : [Rule name=postponePart_12, agendaGroup=MAIN,
salience=0, no-loop=false]
participantPostponementRules/Rule_postponePart_12_0.java (8:343)
: The field BooleanAnswer.answer is not visible
at org.drools.rule.Package.checkValidity(Package.java:408)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:288)
at
com.acs.gs.juror.bizstrategy.PostponementStrategy.init(PostponementStrategy.
java:129)
... 14 more
)
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.TestSuite$1.runTest(TestSuite.java:263)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3T
estReference.java:128)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
8)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
.java:196)
Help for a newbie, please?
Thanks.
Thom Hehl
Sr. eJuror Architect
* Office (859) 277-8800 x 144
* Thomas.Hehl(a)acs-inc.com <mailto:Thomas.Hehl@acs-inc.com>
ACS, Inc.
Government Solutions
1733 Harrodsburg Road
Lexington, KY 40504-3617
This e-mail message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the sender
by reply e-mail and destroy all copies of the original message and notify
sender via e-mail at Thomas.Hehl(a)acs-inc.com
<mailto:Thomas.Hehl@acs-inc.com> or by telephone at 859-277-8800 ext. 144.
Thank you.
17 years, 3 months
NPE on DecisionTable rule
by Hehl, Thomas
Hey, gang!
I have a decision table that generated the following rule:
{other rules removed}
#From row number: 19
rule "postponePart_19"
when
PoolInfo(courtLocation == "101")
PoolInfo(statusCode >= 0, statusCode <= 2)
PoolInfo(numberFta < 1)
PoolInfo(numberOfDeferralsPosted < 2)
PoolInfo(daysBeforeSummons>= 2, daysBeforeSummons<= 999)
then
answer.setAnswer(true);
end
I call these rules with the following code (I build the ruleBase at the
beginning in the factory method to be used by everything:
StatelessSession session =
participantRuleBase.newStatelessSession();
//now create some test data
PoolInfo pool = part.getActivePool();
BooleanAnswer answer = new BooleanAnswer();
Object[] rules = new Object[]{pool, answer};
session.execute(rules);
return answer.isTrue();
BooleanAnswer is simply a convenience object I created to store the answer
from the rules. (If anyone has a better way to do this, please let me know.)
I got the following stack trace:
java.lang.NullPointerException
at
com.acs.gs.juror.bo.Rule_postponePart_19_0.consequence(Rule_postponePart_19_
0.java:6)
at
com.acs.gs.juror.bo.Rule_postponePart_19_0ConsequenceInvoker.evaluate(Rule_p
ostponePart_19_0ConsequenceInvoker.java:20)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.j
ava:430)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.j
ava:402)
at
org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java
:128)
I'm a newbie and have no idea what to do next. Please help.
Thanks.
Thom Hehl
Sr. eJuror Architect
* Office (859) 277-8800 x 144
* Thomas.Hehl(a)acs-inc.com <mailto:Thomas.Hehl@acs-inc.com>
ACS, Inc.
Government Solutions
1733 Harrodsburg Road
Lexington, KY 40504-3617
This e-mail message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the sender
by reply e-mail and destroy all copies of the original message and notify
sender via e-mail at Thomas.Hehl(a)acs-inc.com
<mailto:Thomas.Hehl@acs-inc.com> or by telephone at 859-277-8800 ext. 144.
Thank you.
17 years, 3 months
Date comparasion does not work in 3.0.6?
by jack wu
can any one confirm this:
i tested:
1. m : Message( date > "2007-Mar-12", message : message )
2. m : Message( date == "2007-Mar-12", message : message )
3. m : Message( date < "2007-Mar-12", message : message )
only 2 works. 1 and 3 throws:
java.lang.RuntimeException: Operator '40' does not exist for StringEvaluator
at org.drools.base.evaluators.StringFactory.getStringEvaluator(Unknown Source)
at org.drools.base.EvaluatorFactory.getEvaluator(Unknown Source)
at org.drools.base.EvaluatorFactory.getEvaluator(Unknown Source)
at org.drools.semantics.java.RuleBuilder.getEvaluator(Unknown Source)
at org.drools.semantics.java.RuleBuilder.build(Unknown Source)
at org.drools.semantics.java.RuleBuilder.build(Unknown Source)
at org.drools.semantics.java.RuleBuilder.build(Unknown Source)
at org.drools.semantics.java.RuleBuilder.build(Unknown Source)
at org.drools.compiler.PackageBuilder.addRule(Unknown Source)
at org.drools.compiler.PackageBuilder.addPackage(Unknown Source)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(Unknown Source)
at com.sample.DroolsTest.readRule(DroolsTest.java:57)
at com.sample.DroolsTest.main(DroolsTest.java:23)
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/
17 years, 3 months
Problem in the set variable in the rules
by grupo cft ing sostware
hi list, Y have the next problem in the rules:
rule "Valida Duracion nula"
when
$v : Validaciones(flag == 0)
then
$v.setFlag(1);
System.out.println( "obtenemos flag " + $v.getFlag() );
end
rule "valida Duracion Destino"
when
$v: Validaciones(flag == 0)
then
$v.setResultado("l");
System.out.println( "obtenemos " + $v.getResultado());
System.out.println( "obtenemos cantidad seg dos " + $v.getFlag() );
end
the problem is:
the flag variable values begin in 0 (in the class in java), in the first
rules the change a 1 (setFlag) and
Should not execute rule seconds her, But it is executed, why?
thanks.
17 years, 3 months
Functionality/Performance Test Results
by Robert Crawford
Our users are asking to be able to specify custom validations in our
application. I've been undecided whether to use a rules engine or write
our own dynamic validation code.
While it's admittedly still in the "toy problem" stage, I tried using
drools in place of some existing hand-coded validation. The drools version
took the SAME amount of time.
Then I added another rule, to simulate the types of validations our users
want to add, and re-ran.
Again, SAME time.
Admittedly, database access was the big time consumer -- average of 6
seconds per unit of work, and about 15 units of work per test -- but it
was the same for both the rules-based and hand-coded validations.
Excellent work, everyone! You've made my life much, much simpler!
17 years, 3 months