{"record":{"id":"e260bd5426bdbc21","repo":"flowable/flowable-engine","slug":"error-while-evaluating-expression-expressiontex","errorCode":null,"errorMessage":"Error while evaluating expression: ${expressionText}","messagePattern":"Error while evaluating expression: (.+?)","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/el/JuelExpression.java","lineNumber":59,"sourceCode":"        this.valueExpression = valueExpression;\n        this.expressionText = expressionText;\n    }\n\n    @Override\n    public Object getValue(VariableContainer variableContainer) {\n        ELContext elContext = Context.getProcessEngineConfiguration().getExpressionManager().getElContext((VariableScope) variableContainer);\n        try {\n            ExpressionGetInvocation invocation = new ExpressionGetInvocation(valueExpression, elContext);\n            Context.getProcessEngineConfiguration()\n                    .getDelegateInterceptor()\n                    .handleInvocation(invocation);\n            return invocation.getInvocationResult();\n        } catch (PropertyNotFoundException pnfe) {\n            throw new ActivitiException(\"Unknown property used in expression: \" + expressionText, pnfe);\n        } catch (MethodNotFoundException mnfe) {\n            throw new ActivitiException(\"Unknown method used in expression: \" + expressionText, mnfe);\n        } catch (ELException ele) {\n            throw new ActivitiException(\"Error while evaluating expression: \" + expressionText, ele);\n        } catch (Exception e) {\n            throw new ActivitiException(\"Error while evaluating expression: \" + expressionText, e);\n        }\n    }\n    \n    @Override\n    public void setValue(Object value, VariableContainer variableContainer) {\n        ELContext elContext = Context.getProcessEngineConfiguration().getExpressionManager().getElContext((VariableScope) variableContainer);\n        try {\n            ExpressionSetInvocation invocation = new ExpressionSetInvocation(valueExpression, elContext, value);\n            Context.getProcessEngineConfiguration()\n                    .getDelegateInterceptor()\n                    .handleInvocation(invocation);\n        } catch (Exception e) {\n            throw new ActivitiException(\"Error while evaluating expression: \" + expressionText, e);\n        }\n    }\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/el/JuelExpression.java#L41-L77","documentation":"JuelExpression.getValue catches ELException and any other Exception while evaluating the expression and wraps it into this ActivitiException carrying the expression text as cause. Unlike unknown property/method, this signals the expression resolved but evaluation itself failed (exception in invoked code, type conversion, resolver misconfiguration).","triggerScenarios":"The expression ${...} resolved to a method/property whose invocation threw (NPE inside the delegate method, ClassCastException during EL coercion), or the EL context/resolver itself failed (e.g. missing ELResolver for the variable).","commonSituations":"NullPointerException inside a bean method called from an expression, type mismatch between process variable and expected parameter, custom ELResolver throwing, or evaluation during deserialization with missing context.","solutions":["Inspect the cause chain of the ActivitiException — the root exception points at the real failure inside the expression evaluation.","Fix the underlying bug in the method/bean invoked by the expression (null checks, argument types).","Add null guards in the expression itself: ${myVar != null ? myService.doIt(myVar) : ''}.","Verify the process engine configuration registers the correct resolvers (Spring/beans resolver) for the variables referenced."],"exampleFix":"// before: NPE inside invoked bean\npublic BigDecimal total(Order o){ return o.getAmount(); }\n// after\npublic BigDecimal total(Order o){ return o == null ? BigDecimal.ZERO : o.getAmount(); }","handlingStrategy":"try-catch","validationCode":"// Guard inputs used inside expressions before evaluating:\nObject o = container.getVariable(\"order\");\nif (o == null) throw new IllegalStateException(\"'order' variable required before expression evaluation\");","typeGuard":null,"tryCatchPattern":"try {\n  Object v = juelExpression.getValue(container);\n} catch (ActivitiException e) {\n  Throwable root = e;\n  while (root.getCause() != null) root = root.getCause();\n  logger.error(\"Expression '{}' failed due to {}\", e.getMessage(), root, e);\n  throw e;\n}","preventionTips":["Always log/inspect the cause chain — the root cause identifies the failing code inside the expression.","Add null checks at the start of bean methods called from expressions.","Avoid complex logic in EL; move it to JavaDelegate code that can be unit-tested.","Cover expression evaluation paths with integration tests using realistic variable values."],"tags":["expression","el","evaluation-failure"],"backgroundTag":"invalid-argument-value","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}