It is just a test case used to bring up the issue. The real rule condition in my business logic is more complex, like <br>Order( id == &#39;...&#39;, $msg.date &gt; &#39;...&#39;, num == $msg.num ). Of course I can change to use Message as Pattern to work aournd, but it is too tricky, right? And no matter the usage is weird or not, it is legal, right? <br>
<br>I am using Drools 4.0.7. If later release fixes this bug, I may try to upgrade. I don&#39;t want to change LHS. It will bring much effort in my project.<br><br><br><div class="gmail_quote">On 30 March 2012 14:09, FrankVhh <span dir="ltr">&lt;<a href="mailto:frank.vanhoenshoven@agserv.eu" target="_blank">frank.vanhoenshoven@agserv.eu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Let me rephrase my question:<br>
<br>
As date is an attribute of message, why don&#39;t you use:<br>
<br>
               $msg : Message( date &gt; &quot;...&quot;)<br>
<br>
Constraining an attribute of Message in the Order pattern seems a weird<br>
thing to do.<br>
<br>
<br>
<br>
Zeke-3 wrote<br>
<div>&gt;<br>
&gt; It seems not work.<br>
&gt; When I try<br>
</div><div>&gt; *$msg : Message($date : date)<br>
&gt; Order ( $date &gt; &quot;Mar-01-2012&quot; )*<br>
</div><div>&gt; I meet error &quot;Unable to create Field Extractor for &#39;$date&#39; of<br>
&gt; &#39;[ClassObjectType class=org.drools.examples.HelloWorldExample$Second]&#39; in<br>
&gt; rule &#39;default&#39; : [Rule name=default, agendaGroup=MAIN, salience=0,<br>
&gt; no-loop=false]&quot;<br>
&gt;<br>
&gt; When I try<br>
</div>&gt; *$msg : Message($date : date)<br>
&gt; eval ( $date &gt; &quot;Mar-01-2012&quot; )*<br>
<div>&gt; If the dialect is &quot;java&quot;, I meet error &quot;Rule Compilation error : [Rule<br>
&gt; name=default, agendaGroup=MAIN, salience=0, no-loop=false]<br>
&gt;     org/drools/examples/test/Rule_default_0.java (8:354) : The operator &gt;<br>
&gt; is undefined for the argument type(s) Date, String&quot;<br>
&gt; If the dialect is &quot;mvel&quot;, I meet the same ClassCastException.<br>
&gt;<br>
</div><div><div>&gt; On 29 March 2012 22:28, FrankVhh &amp;lt;frank.vanhoenshoven@&amp;gt; wrote:<br>
&gt;<br>
&gt;&gt; This may sound a bit rude, but... why would you want to do such a thing?<br>
&gt;&gt;<br>
&gt;&gt; If there is a constraint on the message, then why not put that constraint<br>
&gt;&gt; in<br>
&gt;&gt; the message structure?<br>
&gt;&gt;<br>
&gt;&gt; Btw, I think it would work by using eval($date &lt; &quot;...&quot;) but see no use<br>
&gt;&gt; for<br>
&gt;&gt; it either.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Joe Zendle wrote<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; did you try:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;  *$msg : Message($date : date)<br>
&gt;&gt; &gt; Order ( $date &gt; &quot;Mar-01-2012&quot; )*<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; 2012/3/29 Zeke &amp;lt;xanadu860122@&amp;gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Hi, guys:<br>
&gt;&gt; &gt;&gt;   I meet a strange issue and need your help again... I am using Drools<br>
&gt;&gt; &gt;&gt; 4.0.7.<br>
&gt;&gt; &gt;&gt;   When my rule condition is as *Message( date &gt; &quot;Mar-01-2012&quot; )*,<br>
&gt;&gt; &gt;&gt; everything is OK. But if I change it to be as below:<br>
&gt;&gt; &gt;&gt;   *$msg : Message()<br>
&gt;&gt; &gt;&gt;   Order ( $msg.date &gt; &quot;Mar-01-2012&quot; )*<br>
&gt;&gt; &gt;&gt;   I will meet &quot;java.lang.String cannot be cast to java.util.Date&quot;<br>
&gt;&gt; &gt;&gt; ClassCastException. &quot;Order&quot; is another fact. I attach the exception<br>
&gt;&gt; call<br>
&gt;&gt; &gt;&gt; stack. Please check it. It looks like a bug to me. Do we fix it in<br>
&gt;&gt; later<br>
&gt;&gt; &gt;&gt; release? If so, can you tell me which release contains the fix?<br>
&gt;&gt; Thanks!<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; rules-users mailing list<br>
&gt;&gt; &gt;&gt; rules-users@.jboss<br>
&gt;&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;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; rules-users mailing list<br>
&gt;&gt; &gt; rules-users@.jboss<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;<br>
&gt;&gt; --<br>
&gt;&gt; View this message in context:<br>
&gt;&gt; <a href="http://drools.46999.n3.nabble.com/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3867832.html" target="_blank">http://drools.46999.n3.nabble.com/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3867832.html</a><br>


&gt;&gt; Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; rules-users@.jboss<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;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; rules-users@.jboss<br>
&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>
<br>
<br>
--<br>
</div></div>View this message in context: <a href="http://drools.46999.n3.nabble.com/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3870029.html" target="_blank">http://drools.46999.n3.nabble.com/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3870029.html</a><br>


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