Unable to cast object in rules THEN clause - used to work in older version.

47 views
Skip to first unread message

Swayingfish

unread,
May 31, 2022, 1:14:19 PM5/31/22
to Drools Usage
Hello,

I'm running on Optaplanner 8.0.0.Final, the corresponding drools version I believe is 7.46.0.Final. This rule used to work fine on Optaplanner 7 (7.45.0.Final, drools version is also 7.45.0.Final).

I have a rule that looks like this:

rule "a_rule"
when
    $shiftList: List() from accumulate($shiftSlot: ShiftSlot(true))
then
    for(int i = 0; i < $shiftList.size(); i++) {
        ShiftSlot shiftObject = (ShiftSlot) $shiftList.get(i);
    }
    doSomething();
end

Running it will throw

Exception in thread "main" java.util.NoSuchElementException: Node argument doesn't contain typed expression!

If I remove the line "ShiftSlot shiftObject = (ShiftSlot) $shiftList.get(i);" or replace it with 

"Object shiftObject = $shiftList.get(i);" it runs fine, but it will be useless because I need to call methods from it later.

Anybody know what's wrong? The complete error stack trace shown below.


Thanks,

Augusterror.PNG


Toshiya Kobayashi

unread,
Jun 18, 2022, 8:39:22 PM6/18/22
to Drools Usage
Hi,

The issue has been fixed in Drools 7.53.0.Final. Regarding Optaplanner, the latest versions is 8.22.1.Final that works with Drools 8.22.1.Beta that is also fixed. Could you try with the latest?

Regards,
Toshiya

2022年6月1日水曜日 2:14:19 UTC+9 swayi...@gmail.com:
Reply all
Reply to author
Forward
0 new messages