<br>&nbsp;&nbsp;&nbsp;&nbsp; Can you plz show us the DRL instead of the DSLR for your rule? use the DRLViewer tab for that... <br><br><div class="gmail_quote">2008/12/15 Olivier THIERRY <span dir="ltr">&lt;<a href="mailto:olivier.thierry@gmail.com">olivier.thierry@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
I use drools 4.0.7 and I encounter a problem calling a function from a<br>
rule written for mvel dialect.<br>
<br>
The function I need to call has this signature :<br>
<br>
function VOCounter createCounter(org.drools.spi.KnowledgeHelper<br>
drools, String code, Number number)<br>
<br>
When I call this function, I want to assign result to a variable, for<br>
example to insert it to working memory later, or just to use it in<br>
another function call.<br>
So I wrote something like that (I am writing a DSL so part of the code is DSL ):<br>
<br>
rule &quot;CALCUL_RELICAT_CP&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;salience 8<br>
 &nbsp; &nbsp; &nbsp; &nbsp;no-loop<br>
 &nbsp; &nbsp; &nbsp; &nbsp;when<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;not There is a counter called &quot;RELICAT_CP&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;There is a date called &quot;startDate&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;There is a date called &quot;endDate&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;There is a counter called &quot;SOLDE_CP_CUM&quot; with<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- start date is last year<br>
 &nbsp; &nbsp; &nbsp; &nbsp;then<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VOCounter $relicat = createCounter(drools,&quot;RELICAT_CP&quot;,$SOLDE_CP_CUM.value);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert($relicat);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Copy counter $SOLDE_CP_CUM to SOLDE_RELICAT_CP<br>
end<br>
<br>
But I have the following stack trace :<br>
<br>
org.drools.spi.ConsequenceException:<br>
org.mvel.UnresolveablePropertyException: unable to resolve token:<br>
createCounter(drools,&quot;RELICAT_CP&quot;,$SOLDE_CP_CUM.value)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.drools.base.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:13)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:558)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:518)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:475)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:439)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at fr.horoquartz.t4.test.drools.TestRuleBase.executeRuleWithDsl(TestRuleBase.java:120)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at fr.horoquartz.t4.test.drools.Test1.testDsl(Test1.java:39)<br>
Caused by: org.mvel.UnresolveablePropertyException: unable to resolve<br>
token: createCounter(drools,&quot;RELICAT_CP&quot;,$SOLDE_CP_CUM.value)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:129)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java:24)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.mvel.ExecutableAccessor.getValue(ExecutableAccessor.java:45)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.mvel.ast.TypedVarNode.getReducedValueAccelerated(TypedVarNode.java:43)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.mvel.MVEL.executeExpression(MVEL.java:235)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:48)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:554)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;... 34 more<br>
<br>
What is strange is that it works if I don&#39;t assign function call<br>
result to a variable. For example the following works &nbsp;:<br>
<br>
insert (createCounter(drools,&quot;RELICAT_CP&quot;,$SOLDE_CP_CUM.value));<br>
<br>
It also works if I assign $SOLDE_CP_CUM.value to a temporary variable<br>
and use it for function call :<br>
<br>
Number $val = $SOLDE_CP_CUM.value;<br>
VOCounter $relicat = createCounter(drools,&quot;RELICAT_CP&quot;,$val);<br>
insert($relicat);<br>
<br>
I had not this problem using java dialect. I understand nothing in<br>
what happens ... Anyone has an idea what the problem is ?<br>
<br>
Thanks in advance,<br>
<br>
Olivier<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> &nbsp;Edson Tirelli<br> &nbsp;JBoss Drools Core Development<br> &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>