easy-rules icon indicating copy to clipboard operation
easy-rules copied to clipboard

MVEL variables throw PropertyAccessException unresolvable property or identifier after upgrade

Open aquacode opened this issue 2 years ago • 1 comments

I followed the v3 --> v4 upgrade instructions and all mvel yaml file rules compile and most run fine. However, a few are throwing errors in the actions when attempting to access variables (seems the ctx is null and the variable can't be accessed).

Is there another step in the version upgrade? Most of our variables are Optionals that we use get(), isPresent, and orElse functions on.

Here's a sample code that worked on 3.3 but fails on 4.1:

---
name: "zzz_custom"
condition: >
  parameterValues = config.get('parameters');
  parameterValues.isPresent();
actions:
  - >
    for(rule:parameterValues.get()){
      if(rule.match==true){
        for(mod:rule.fields.entrySet()){
          org.apache.commons.beanutils.BeanUtils.copyProperty(callParameters,mod.key,mod.value);
        }
      }
    }

The error occurs in the actions on the line trying to access parameterValues.get() with PropertyAccessException. If I insert this call parameterValues = config.get('parameters'); then it works.

I have other mvel yaml files that are having a similar problem, but so far, I've not been able to solve it simply by re-initializing the variable like above.

aquacode avatar Sep 12 '22 22:09 aquacode

I will be great if you can share a maven repo with a sample

dvgaba avatar Sep 14 '22 14:09 dvgaba