<div>Thanks for your help, Edson. </div>  <div>collect works in my simple test now, but not when I integrate with my code. Is there an easy way to debug LHS to see if collect stmt is evaluated?&nbsp; I notice IllegalAccessError<BR>&nbsp;since my app will load a selected list of jars upfront, so my questions are:</div>  <div>1) Can this error break collect?</div>  <div>2) How can I fix this error still using our own classLoader?</div>  <div>&nbsp;</div>  <div>Here is the stack trace:</div>  <div>2007 Aug 15, 09:08:13:193&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exception IllegalAccessError<BR>java.lang.IllegalAccessError: class org.drools.reteoo.InitialFactImplShadowProxy cannot access its superclass org.drools.reteoo.Init<BR>ialFactImpl<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.defineClass1(Native Method)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.defineClass(Unknown
 Source)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.rule.MapBackedClassLoader.fastFindClass(MapBackedClassLoader.java:60)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.rule.MapBackedClassLoader.loadClass(MapBackedClassLoader.java:79)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.loadClass(Unknown Source)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.reteoo.Rete$ObjectTypeConf.loadOrGenerateProxy(Rete.java:379)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.reteoo.Rete$ObjectTypeConf.defineShadowProxyData(Rete.java:344)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.reteoo.Rete$ObjectTypeConf.&lt;init&gt;(Rete.java:320)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.reteoo.Rete.assertObject(Rete.java:145)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 at org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:163)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1241)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:858)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:822)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:623)<BR></div>  <div>&nbsp;</div>  <div>Thanks,</div>  <div>-av</div>  <div>&nbsp;</div>  <div><BR><B><I>Edson Tirelli &lt;tirelli@post.com&gt;</I></B> wrote:</div>  <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>&nbsp;&nbsp; No single simple answer here. You need to check what would better fit
 your use case. <BR>&nbsp;&nbsp; The thing is: it is not possible to limit the number of matches to a collect statement... all matching instances WILL match it and be collected. <BR><BR>&nbsp;&nbsp; No really "clean" way I can think about, but a few possible options (haven't executed them, but shall work):<BR><BR>1. Simply execute the actions multiple times in the consequence:<BR><BR>  <DIV>when </DIV><FONT size=2><FONT size=2>  <DIV align=left>&nbsp;&nbsp; eventList : LinkedList( $size : size &gt;= 5 ) from collect( Event(text matches ".*rule5.*"<FONT size=2> )) <BR></FONT><B><FONT color=#960000 size=2>then<BR>&nbsp;&nbsp; for( int i = 0; i &lt; $size/5; i++ )<BR></FONT></B></DIV></FONT></FONT><FONT size=2>  <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(<FONT color=#008000 size=2>"rule5 is fired "</FONT><FONT size=2> + eventList.size ());</FONT> <BR></DIV></FONT>end<BR><BR>2. Flag used facts:<BR><BR>  <DIV>when</DIV><FONT size=2><FONT size=2>  <DIV
 align=left>&nbsp;&nbsp; eventList : LinkedList( size &gt;= 5 ) from collect( Event(text matches ".*rule5.*", processed == false<FONT size=2> )) <BR></FONT><B><FONT color=#960000 size=2>then<BR></FONT></B><FONT size=+0><FONT size=2>&nbsp;&nbsp; System.out.println(<FONT color=#008000 size=2>"rule5 is fired "</FONT><FONT size=2> + eventList.size());</FONT> <BR></FONT></FONT><B><FONT color=#960000 size=2>&nbsp;&nbsp; for( int i = 0; i &lt; 5; i++ ) {<BR><SPAN style="FONT-WEIGHT: bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Event e = </SPAN></FONT></B><FONT size=2><FONT size=2><B><FONT color=#960000 size=2><SPAN style="FONT-WEIGHT: bold">(Event) eventList.get ( i );</SPAN></FONT></B></FONT></FONT><B><FONT color=#960000 size=2><SPAN style="FONT-WEIGHT: bold"></SPAN><BR><SPAN style="FONT-WEIGHT: bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.setProcessed( true );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; update( e ); <BR></SPAN></FONT></B></DIV></FONT></FONT><FONT size=2> 
 <DIV>&nbsp;&nbsp; }<BR></DIV></FONT>end<BR><BR>2. Retract used facts:<BR><BR>  <DIV>when</DIV><FONT size=2><FONT size=2>  <DIV align=left>&nbsp;&nbsp; eventList : LinkedList( size &gt;= 5 ) from collect( Event(text matches ".*rule5.*"<FONT size=2> )) <BR></FONT><B><FONT color=#960000 size=2>then<BR></FONT></B><FONT size=+0><FONT size=2>&nbsp;&nbsp; System.out.println(<FONT color=#008000 size=2>"rule5 is fired "</FONT><FONT size=2> + eventList.size());</FONT> <BR></FONT></FONT><B><FONT color=#960000 size=2>&nbsp;&nbsp; for( int i = 0; i &lt; 5; i++ ) {<BR><SPAN style="FONT-WEIGHT: bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Event e = </SPAN></FONT></B><FONT size=2><FONT size=2><B><FONT color=#960000 size=2><SPAN style="FONT-WEIGHT: bold">(Event) eventList.get( i );</SPAN></FONT></B></FONT></FONT> <B><FONT color=#960000 size=2><SPAN style="FONT-WEIGHT: bold"></SPAN><BR><SPAN style="FONT-WEIGHT: bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; retract( e );
 <BR></SPAN></FONT></B></DIV></FONT></FONT><FONT size=2>  <DIV>&nbsp;&nbsp; }<BR></DIV></FONT>end<BR><BR>&nbsp;&nbsp;&nbsp; Hope it helps.<BR><BR>&nbsp;&nbsp;&nbsp; Edson<BR><SPAN class=gmail_quote></SPAN><BR>  <DIV><SPAN class=gmail_quote>2007/8/10, Anh Vuong &lt;<A href="mailto:anhtvuong@yahoo.com">anhtvuong@yahoo.com</A>&gt;:</SPAN>  <BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">  <DIV>Hi,</DIV>  <DIV>I'd like to use keyword collect to do my filtering but its behaviour confused me, please advise. I greatly appreciate your help.</DIV>  <DIV>&nbsp;</DIV>  <DIV>Problem 1:</DIV>  <DIV>&nbsp;</DIV>  <DIV>when </DIV><FONT size=2><FONT size=2>  <DIV align=left>eventList : LinkedList(size == 5)</DIV>  <DIV align=left>from collect( Event(text matches </DIV></FONT><FONT color=#008000 size=2>".*rule5.*"</FONT><FONT size=2> ))   <DIV align=left></DIV>  <DIV align=left></DIV></FONT><B><FONT color=#960000
 size=2>then</FONT></B></FONT><FONT size=2>   <DIV>System.out.println(</DIV></FONT><FONT color=#008000 size=2>"rule5 is fired " </FONT><FONT size=2>+ eventList.size());</FONT>   <DIV><FONT size=2></FONT>&nbsp;</DIV>  <DIV><FONT size=2>I still do not see&nbsp;any log msg after adding 5+ events. Is something wrong with my rule?</FONT></DIV>  <DIV>&nbsp;</DIV>  <DIV>Problem 2:</DIV>  <DIV>&nbsp;</DIV>  <DIV>when</DIV>  <DIV>event: Event(text matches <FONT color=#008000 size=2>".*rule5.*"</FONT><FONT size=2> ))</FONT></DIV><FONT size=2><FONT size=2>  <DIV align=left>eventList : LinkedList(size == 5)</DIV>  <DIV align=left>from collect( Event(text == event.text)</DIV></FONT><FONT size=2>  <DIV align=left></DIV>  <DIV align=left></DIV></FONT><B><FONT color=#960000 size=2>then </FONT></B></FONT><FONT size=2>  <DIV>System.out.println(</DIV></FONT><FONT color=#008000 size=2>"rule5 is fired "</FONT><FONT size=2> + eventList.size());</FONT>   <DIV>&nbsp;</DIV>  <DIV><FONT size=2>After
 adding 5 events, I see&nbsp;5 log msg instead of one as I'd expect. </FONT></DIV>  <DIV>If I add more events, I will see more log. How do I tell LHS&nbsp; to reset the count from 0.</DIV>  <DIV>Basically, I want to take 1 event out of 5 similar events (suppressing filtering). So if there are 10 similar events, my RHS should activate 2 times, not 10 times. </DIV>  <DIV>&nbsp;</DIV>  <DIV>Thanks,</DIV><SPAN class=sg>  <DIV>-av</DIV></SPAN><SPAN class=ad>  <DIV><FONT size=2></FONT>&nbsp;</DIV>  <div></div>  <HR SIZE=1>  Ready for the edge of your seat? <A onclick="return top.js.OpenExtLink(window,event,this)" href="http://us.rd.yahoo.com/evt=48220/*http://tv.yahoo.com/" target=_blank>Check out tonight's top picks</A> on Yahoo! TV.   <div></div></SPAN><BR>_______________________________________________<BR>rules-users mailing list<BR><A onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org </A><BR><A
 onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR><BR></BLOCKQUOTE></DIV><BR><BR clear=all><BR>-- <BR>&nbsp;&nbsp;Edson Tirelli<BR>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<BR>&nbsp;&nbsp;Office: +55 11 3529-6000<BR>&nbsp;&nbsp;Mobile: +55 11 9287-5646<BR>&nbsp;&nbsp;JBoss, a division of Red Hat @ <A href="http://www.jboss.com/">www.jboss.com</A> _______________________________________________<BR>rules-users mailing list<BR>rules-users@lists.jboss.org<BR>https://lists.jboss.org/mailman/listinfo/rules-users<BR></BLOCKQUOTE><BR><p>&#32;

      <hr size=1>Park yourself in front of a world of choices in alternative vehicles.<br><a href="http://us.rd.yahoo.com/evt=48246/*http://autos.yahoo.com/green_center/;_ylc=X3oDMTE5cDF2bXZzBF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDZ3JlZW4tY2VudGVy">Visit the Yahoo! Auto Green Center.</a>