MVEL Projections compile error

32 views
Skip to first unread message

Josh Kropf

unread,
Dec 8, 2021, 10:01:18 PM12/8/21
to Drools Usage
I'm attempting to use projections (list comprehension) in a mvel rule consequence, however it fails to compile.

foo = (toUpperCase() in ["a", "b", "c"]);

Error: unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.toUpperCase()

Setting the system property "drools.dialect.mvel.strict=false" will work around this problem, but I'm reluctant to do this system wide in case there is a negative performance impact (I don't know if that's a valid concern).

Another workaround is to declare a variable named "$", but this is also not ideal since that would limit the use of one projection in the current scope since the "$" variable can't be declared again to change the type.

String $ = null;
foo = ($.toUpperCase() in ["a", "b", "c"]);

Is there a different variable name other than "$" for accessing the list element in a projections statement like this? Or some other workaround? Should I just disable strict mode?

Toshiya Kobayashi

unread,
Dec 23, 2021, 7:44:06 AM12/23/21
to Drools Usage
Hello,

Sorry that I don't have a good mvel solution for your issue. As you haven't got an answer for weeks, I just want to suggest to use a Java method (e.g. write a method like MyUtils.collectWithUpperCase(String... strings) then call it in RHS) rather than mvel logic. It should be easier.

Regards,
Toshiya

2021年12月9日木曜日 12:01:18 UTC+9 jo...@opstack.us:
Reply all
Reply to author
Forward
0 new messages