When - Then In DSL Rule
by IPatel
A basic question about writing DSL rules. I am not sure if i am using correct
terminology to ask the following question.
I have the following in my DSL Configuration:
[when] When the transcation is credit= $item:Item(CDIndicator == "Credit")
[then] Charge a fee = $item.setChargeFee (true)
[when] When the loan application is submitted =
$application:LoanApplication(Submitted == true)
Now in my business rules tab. I have the rule that when the loan application
is submitted then charge a fee.
so i selected something like this on the Business Rules tab:
When
1. When the loan application is submitted
THEN
1. Charge a fee
When i test this scenario, the system does not recognize "Then" part. So the
question is *Can i not use the "Then" part defined in DSL format with
different "When" part??*
--
View this message in context: http://drools.46999.n3.nabble.com/When-Then-In-DSL-Rule-tp4022407.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Easy mistake...
by Willem van Asperen
Hi All,
Just wanted to share with you an easy mistake. This is done running
Drools 5.5.0.Final.
Imagine a fact
|Cheese (||
|| creationTick : double||
|| preservationTicks : double||
||)|
Then the following does not do what you expect:
|rule "dump old cheese"||
|| when||
|| $c : Cheese( $sbd : creationTick + preservationTicks )||
|| CurrentTime( tick >= $sbd )||
|| then||
|| System.out.println("||we have to dump "+$c);||
||end|
You would expect that $c is dumped when current time has passed
creationTick + preservationTicks. But no. The variable $sbd is bound to
creationTick /before/ the preservationTicks are added!! I must say that
I do not quite understand how ($sbd : creationTick) + preservationTicks
resolves to "true" to make the premise succeed... Maybe because it is != 0?
I found that it should be:
|rule "dump old cheese"||
|| when||
|| $c : Cheese( $sbd : (creationTick + preservationTicks) )||
|| CurrentTime( tick >= $sbd )||
|| then||
|| System.out.println("we have to dump "+$c);||
||end|
This makes sense. Now $sbd is bound to the result of the addition. But
it is an easy trap!!
Regards,
Willem
12 years, 10 months
[Bug] 5.5.0 Correctly compiled DRL runs into run time error: "incompatible types"
by Wolfgang Laun
Below is a fully self-contained DRL that compiles correctly but runs
into a runtime error when the LHS of rule "match" is evaluated. The
"culprit" is the test "this != $c", but one would expect simply a true
result from the comparison.
declare Person
name: String
end
declare Customer
extends Person
rating: int
end
declare Employee
extends Person
wage: int
end
rule initphone
salience 100
when
then
insert( new Customer( "Joe", 100 ) );
insert( new Employee( "Paul", 2100 ) );
end
rule match
when
$c: Customer()
$e: Employee( this != $c )
then
System.out.println( "c/e " + $c + " " + $e );
end
Exception in thread "main" Exception executing consequence for rule
"initphone" in express: [Error: incompatible types in statement: class
express.Customer (compared from: class express.Employee)]
[Near : {... this != $c ....}]
^
[Line: 1, Column: 1]
at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at express.Main.execute(Main.java:92)
at express.Main.main(Main.java:126)
Caused by: [Error: incompatible types in statement: class
express.Customer (compared from: class express.Employee)]
[Near : {... this != $c ....}]
^
[Line: 1, Column: 1]
at org.mvel2.ast.BinaryOperation.<init>(BinaryOperation.java:84)
at org.mvel2.util.CompilerTools.finalizePayload(CompilerTools.java:118)
at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:287)
at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:62)
at org.mvel2.MVEL.compileExpression(MVEL.java:810)
at org.drools.base.mvel.MVELCompilationUnit.compile(MVELCompilationUnit.java:435)
at org.drools.base.mvel.MVELCompilationUnit.getCompiledExpression(MVELCompilationUnit.java:238)
at org.drools.rule.constraint.MvelConstraint.createMvelConditionEvaluator(MvelConstraint.java:206)
at org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:190)
at org.drools.rule.constraint.MvelConstraint.isAllowedCachedRight(MvelConstraint.java:184)
at org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:134)
at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:156)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:192)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:186)
at express.Rule_initphone_aea184dfceb14326841c37daadabfdbc.defaultConsequence(Rule_initphone_aea184dfceb14326841c37daadabfdbc.java:8)
at express.Rule_initphone_aea184dfceb14326841c37daadabfdbcDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at express.Rule_initphone_aea184dfceb14326841c37daadabfdbcDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
... 7 more
12 years, 10 months
Delpoying Guvnor 5.5.0 on Tomcat 7.0.34 does not work
by oresch
I deployed the Tomcat Guvnor war (guvnor-5.5.0.Final-tomcat-6.0.war) and
renamed it to "guvnor". When I start the application I receive the following
error report:
java.lang.NullPointerException
org.jboss.seam.transaction.TransactionServletListener.requestInitialized(TransactionServletListener.java:106)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
java.lang.Thread.run(Thread.java:722)
Can anybody help? I have to admit that this is my first attempt to use
Guvnor Thank you in advance.
Olaf
--
View this message in context: http://drools.46999.n3.nabble.com/Delpoying-Guvnor-5-5-0-on-Tomcat-7-0-34...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Guvnor Calendars
by Anton Nikulin
Hi
I have a problem with calendars in guvnor. I want to use calendars feature
in my rules and I've defined such rule in Guvnor:
rule "CalendarTest"
calendars "AUD Home Loans"
no-loop true
dialect "mvel"
when
then
System.out.println("CALENDAR IS WORKING!!!");
end
When in my application I consume ChangeSet.xml in which i specify recources
in binary format as PKG type, it always fires this rule even if there is no
calendar in session. However, if i defined sources in changeset in DRL
format, everything is ok.
Can you help me, why is it so?
Thanks, Anton
12 years, 10 months
Drools Planner 5.5.0.Final Memory corruption issues
by duggal
I am using Drools Planner for an optimization problem and facing weird memory
corruption issues.
The problem facts and planning entities are JPA entities which have lots of
relationships and are large in size.
When I use a few of the entities, then the solving works ok.
However when I use large number of these entities, then I get strange
exceptions indicating memory corruption in the result. E.g. the serialized
best solution (serialized by me for persistence purposes) appears to be have
invalid class types in members.
I see that there are the following exceptions in the log (for both small and
large data sets) -
Exception in thread "Thread-106" java.lang.RuntimeException: Unknown
accessor type:
org.mvel2.optimizers.impl.refl.collection.ArrayCreator@e7d1626d
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.analyzeAccessor(ConditionAnalyzer.java:264)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.analyzeNode(ConditionAnalyzer.java:250)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.statementToExpression(ConditionAnalyzer.java:467)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.readInvocationParams(ConditionAnalyzer.java:457)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.analyzeAccessor(ConditionAnalyzer.java:345)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.analyzeExpressionNode(ConditionAnalyzer.java:326)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.analyzeAccessor(ConditionAnalyzer.java:286)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.analyzeNode(ConditionAnalyzer.java:250)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.analyzeSingleCondition(ConditionAnalyzer.java:133)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.analyzeCondition(ConditionAnalyzer.java:99)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.ConditionAnalyzer.analyzeCondition(ConditionAnalyzer.java:70)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.MvelConditionEvaluator.getAnalyzedCondition(MvelConditionEvaluator.java:83)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:270)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.MvelConstraint.access$200(MvelConstraint.java:51)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
org.drools.rule.constraint.MvelConstraint$ConditionJitter.run(MvelConstraint.java:250)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
[2/12/13 12:35:34:309 IST] 00000174 SystemErr R at
java.lang.Thread.run(Thread.java:770)
Are these exceptions (which appear benign in the small data set solution)
causing my issue?
Are there any further troubleshooting that I can perform to isolate the root
cause?
Any help will be much appreciated. Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Planner-5-5-0-Final-Memory-corru...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
NullPointerException when using RuleAgent
by IPatel
Hi,
I have been trying to write the following code to automatically deploy any
changes made to the rules. However i am getting nullpointerexception errors.
I see many posts regarding this topic and have tried different options but
the error won;t go away.
public static void main(String[] args) {
try {
FileInputStream file = new
FileInputStream("C:\\Users\\folderabc\\workspace\\Drools
Sample\\bin\\Guvnor.properties");
Properties p = new Properties();
p.load(file);
RuleAgent agent = RuleAgent.newRuleAgent(p); *<-- this is where
it is failing* RuleBase rb = agent.getRuleBase();
WorkingMemory ksession = rb.newStatefulSession();
Car c = new Car("yellow", 2100);
Driver d = new Driver("Isha", 18, c, "lets try it" );
ksession.insert(d);
ksession.fireAllRules();
//logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
/Here are the errors i am getting on my console:/
java.lang.NullPointerException
at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:384)
at org.drools.agent.RuleAgent.configure(RuleAgent.java:368)
at org.drools.agent.RuleAgent.init(RuleAgent.java:268)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:208)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:168)
at kijanowski.GuvnorTest.main(GuvnorTest.java:43)
Any help will be greatly appreciated. Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/NullPointerException-when-using-RuleAge...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months