j-easy / easy-rules

The simple, stupid rules engine for Java
https://github.com/j-easy/easy-rules/wiki
MIT License
4.83k stars 1.04k forks source link

MVEL variables throw PropertyAccessException unresolvable property or identifier after upgrade #395

Open aquacode opened 1 year ago

aquacode commented 1 year ago

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.

dvgaba commented 1 year ago

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