<div dir="ltr">Thanks a lot, this helps alot. now all the errors gone.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 25, 2013 at 1:24 AM, Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">@Mark: There&#39;s really no need to claim additional bugs ;-)<br>
<br>
@Jeetendra: Within a pattern (such as &quot;ProposalLight(...)&quot;) you may<br>
write bindings and constraints,  which are boolean expressions. Older<br>
versions had a much more restricted syntax for constraints, and<br>
general (Java-style) expressions were only peremitted by enclosing<br>
them in &quot;eval(...)&quot;. In 5.5.0, as soon as you open a parenthesis, you<br>
have to stick to plain old Java (or MVEL) syntax, and &quot;eval&quot; is a name<br>
like any other. Recognizing &quot;eval(...)&quot; as the legacy marker for<br>
introducing an expression has to be kept, but only at the outermost<br>
parenthesis nesting level of constraint expressions. See example #1<br>
below:<br>
<br>
### 1 ###<br>
function boolean positive(int a){ return a &gt; 0; }<br>
<br>
// legacy style constraint, use eval() to wrap boolean expression<br>
    $msg: Message( eval(positive($msg.getText().length()))  )<br>
<br>
// modern style: boolean expression<br>
    $msg: Message( positive($msg.getText().length())  )<br>
<br>
// modern style: boolean expression with redundant parentheses<br>
    $msg: Message(  ( positive($msg.getText().length()) )  )<br>
<br>
The next example demostrates that eval is a &quot;soft&quot; keyword, with<br>
recognition restricted to certain places:<br>
<br>
### 2 ###<br>
function boolean eval(int a){ return a &gt; 0; }  //  Why not call a<br>
function &quot;eval&quot;?<br>
<br>
// modern style: boolean expression, parentheses required to bypass<br>
soft &quot;eval&quot; recognition<br>
    $msg: Message( ( eval($msg.getText().length()) ) )<br>
<br>
So, the answer to your question &quot;How can I make it work?&quot; is quite<br>
simple: add a declaration of a boolean function eval, like this:<br>
<br>
   function boolean eval( boolean b ){ return b; }<br>
<br>
<br>
And, please, do not use terms like &quot;throws an exception&quot; when a simple<br>
syntax error is reported.<br>
<span class="HOEnZb"><font color="#888888"><br>
-W<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 25/07/2013, Mark Proctor &lt;<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt; wrote:<br>
&gt; It shouldn&#39;t do, and could be a bug. Can you try 5.6.0.SNAPSOT and see if it<br>
&gt; is still a problem.<br>
&gt;<br>
&gt; Mark<br>
&gt; On 24 Jul 2013, at 18:22, Jeet Singh &lt;<a href="mailto:jeetcyb@gmail.com">jeetcyb@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; Alright, I kinda found out the cause of the exception I am getting,<br>
&gt;&gt; however I am still struggling the reason behind the exception.<br>
&gt;&gt;<br>
&gt;&gt; So DRL_1, this works perfectly fine.<br>
&gt;&gt; package drools;<br>
&gt;&gt; import drools.ProposalLight;<br>
&gt;&gt; import function drools.DateUtil.compareDatesWithTime;<br>
&gt;&gt; rule &quot;Date Rule&quot;<br>
&gt;&gt; when<br>
&gt;&gt;     $obj : ProposalLight(eval(compareDatesWithTime(endDateTime, -2, 6,<br>
&gt;&gt; \&quot;&lt;\&quot;)))<br>
&gt;&gt; then<br>
&gt;&gt;     $obj.addFailedRule(&quot;Date Rule&quot;);<br>
&gt;&gt; end;<br>
&gt;&gt;<br>
&gt;&gt; DRL_2, this doesn&#39;t work. and throws [Error: unable to resolve method<br>
&gt;&gt; using strict-mode: myObject.eval(boolean)]  [Near : {...<br>
&gt;&gt; (eval(compareDatesWithTime(star ....}] ...<br>
&gt;&gt;<br>
&gt;&gt; package drools;<br>
&gt;&gt; import drools.ProposalLight;<br>
&gt;&gt; import function drools.DateUtil.compareDatesWithTime;<br>
&gt;&gt; rule &quot;Date Rule&quot;<br>
&gt;&gt; when<br>
&gt;&gt;     $obj : ProposalLight((eval(compareDatesWithTime(endDateTime, -2, 6,<br>
&gt;&gt; \&quot;&lt;\&quot;))))<br>
&gt;&gt; then<br>
&gt;&gt;     $obj.addFailedRule(&quot;Date Rule&quot;);<br>
&gt;&gt; end;<br>
&gt;&gt;<br>
&gt;&gt; Notice that extra paranthesis around eval(). This is where Drools 5.5<br>
&gt;&gt; throws exception. Can someone please explain why this extra paranthesis<br>
&gt;&gt; throws exception and how can I make it work.<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt; Jeetendra.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Jun 5, 2013 at 1:27 AM, Wolfgang Laun &lt;<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; The error message suggests that you have made a syntactic error in a<br>
&gt;&gt; rule which is not the one you have posted, or you have modified the<br>
&gt;&gt; rule too much to be of any help. Post again, taking great care not to<br>
&gt;&gt; omit anything or to change the cause of the problem. Also, indicate<br>
&gt;&gt; precisely the declaration of the function compareDatesWithTime().<br>
&gt;&gt;<br>
&gt;&gt; -W<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On 04/06/2013, jeetendray &lt;<a href="mailto:jeetcyb@gmail.com">jeetcyb@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Snippet of my DRL .<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; rule &quot;Rev: Start Time &lt; 2 Hours in Future&quot;<br>
&gt;&gt; &gt;       when<br>
&gt;&gt; &gt;               $obj : eval(compareDatesWithTime(startDateTime, -2, 2,<br>
&gt;&gt; &gt; &quot;&lt;&quot;))<br>
&gt;&gt; &gt;       then<br>
&gt;&gt; &gt;               $obj.addFailedRule(&quot;Rev: Start Time &lt; 2 Hours in<br>
&gt;&gt; &gt; Future&quot;);<br>
&gt;&gt; &gt; end<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; This fails during compilation and throws error:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; org.drools.rule.InvalidRulePackage: Unable to Analyse Expression<br>
&gt;&gt; &gt; (eval(compareDatesWithTime(startDateTime, -2, 2, &quot;&lt;&quot;))  ):<br>
&gt;&gt; &gt; [Error: unable to resolve method using strict-mode:<br>
&gt;&gt; &gt; myObject.eval(boolean)]<br>
&gt;&gt; &gt; [Near : {... (eval(compareDatesWithTime(star ....}]<br>
&gt;&gt; &gt;              ^<br>
&gt;&gt; &gt; [Line: 6, Column: 2] : [Rule name=&#39;Proposal - Start time is after<br>
&gt;&gt; &gt; current +<br>
&gt;&gt; &gt; 2 hour&#39;]<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I am using Drools 5.5 and I found the cause that my code runs in strict<br>
&gt;&gt; &gt; mode.. so If I set strict mode to false then this would work. Now I am<br>
&gt;&gt; &gt; not<br>
&gt;&gt; &gt; sure how to make it to false.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Here&#39;s the code I am using:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; PackageBuilderConfiguration packageBuilderConfiguration = new<br>
&gt;&gt; &gt; PackageBuilderConfiguration();<br>
&gt;&gt; &gt; PackageBuilder packageBuilder = new<br>
&gt;&gt; &gt; PackageBuilder(packageBuilderConfiguration);<br>
&gt;&gt; &gt; packageBuilder.addPackageFromDrl(drl.getCharacterStream());<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Can someone please suggest me how to do that??<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks!!!<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt; View this message in context:<br>
&gt;&gt; &gt; <a href="http://drools.46999.n3.nabble.com/How-to-set-drools-dialect-mvel-strict-false-tp4024122.html" target="_blank">http://drools.46999.n3.nabble.com/How-to-set-drools-dialect-mvel-strict-false-tp4024122.html</a><br>

&gt;&gt; &gt; Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; rules-users mailing list<br>
&gt;&gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<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>
</div></div></blockquote></div><br></div>