[rules-users] Drools parser error accessing ArrayList.

Wolfgang Laun wolfgang.laun at gmail.com
Wed Apr 11 11:21:18 EDT 2012


A rather debatable feature has been added: the automatic insertion of
semicolons in MVEL code. The problem surfaces in several constellations
where the naive algorithm thinks that a semicolon should be inserted, e.g.,
after the closing parenthesis of any structured statement (such as "for",
"while", "switch") whenever there is no opening brace following *on the
same line*.

This feature ought to be off-turnable!

-W


On 11 April 2012 16:51, groovenarula <gnarula1 at la-z-boy.com> wrote:

> Hi,
>
> I have a situation where I need to iterate over an ArrayList in the RHS of
> a
> rule. The ArrayList is created in the LHS of the rule as follows :
>
> rule "Hello World"
> dialect "mvel"
>        when
>                $cur    : Message()
>                $others : ArrayList ( size > 0 ) from
> collect(Message(status ==
> $cur.status,  this != $cur ))
>        then
>                for ( int ctr = 0; ctr < $others.size(); ctr++)
>                {
>                        System.out.println((Message) $others.get(ctr));
>                }
> end
>
> This works in Drools 5.1.1.
>
> However it gives the following parser error in Drools 5.2.X :
>
>      Unable to Analyse Expression for ( int ctr = 0; ctr < $others.size();
> ctr++);
>                {
>                        System.out.println((Message) $others.get(ctr));
>                }               ;:
>      [Error: was expecting type: java.lang.Object; but found type:
> <Unknown>]
>      [Near : {... for ( int ctr = 0; ctr < $othe ....}]
>                      ^
>      [Line: 6, Column: 0] : [Rule name='Hello World']
>
>      java.lang.IllegalArgumentException: Could not parse knowledge.
>              at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:50)
>              at com.sample.DroolsTest.main(DroolsTest.java:23)
>
> What am I missing here ? Any insight on a possible solution is appreciated.
> This has become a big stumbling block for us to move from 5.1.1 to 5.2.1.
>
> Thanks in advance,
> Gurvinder
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Drools-parser-error-accessing-ArrayList-tp3902766p3902766.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120411/d351033c/attachment.html 


More information about the rules-users mailing list