{"record":{"id":"00c7edd08a6e1a20","repo":"flowable/flowable-engine","slug":"error-while-evaluating-expression","errorCode":null,"errorMessage":"Error while evaluating expression: ","messagePattern":"Error while evaluating expression: ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/JuelExpression.java","lineNumber":60,"sourceCode":"    }\n    \n    @Override\n    public Object getValue(VariableContainer variableContainer) {\n        ELContext elContext = expressionManager.getElContext(variableContainer);\n        Object originalVariableContainer = elContext.getContext(VariableContainer.class);\n        elContext.putContext(VariableContainer.class, variableContainer);\n        Object originalValueContext = elContext.getContext(EvaluationState.class);\n        elContext.putContext(EvaluationState.class, EvaluationState.READ);\n        try {\n            return resolveGetValueExpression(elContext);\n        } catch (PropertyNotFoundException pnfe) {\n            throw new FlowableException(\"Unknown property used in expression: \" + expressionText + \" with \" + variableContainer, pnfe);\n        } catch (MethodNotFoundException mnfe) {\n            throw new FlowableException(\"Unknown method used in expression: \" + expressionText + \" with \" + variableContainer, mnfe);\n        } catch (FlowableException ex) {\n            throw ex;\n        } catch (Exception e) {\n            throw new FlowableException(\"Error while evaluating expression: \" + expressionText + \" with \" + variableContainer, e);\n        } finally {\n            elContext.putContext(EvaluationState.class, originalValueContext);\n            elContext.putContext(VariableContainer.class, originalVariableContainer);\n        }\n    }\n\n    protected Object resolveGetValueExpression(ELContext elContext) {\n        return valueExpression.getValue(elContext);\n    }\n\n    @Override\n    public void setValue(Object value, VariableContainer variableContainer) {\n        ELContext elContext = expressionManager.getElContext(variableContainer);\n        Object originalVariableContainer = elContext.getContext(VariableContainer.class);\n        elContext.putContext(VariableContainer.class, variableContainer);\n        Object originalValueContext = elContext.getContext(EvaluationState.class);\n        elContext.putContext(EvaluationState.class, EvaluationState.WRITE);\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/el/JuelExpression.java#L42-L78","documentation":"JuelExpression.getValue's catch-all wraps any non-Flowable Exception during expression evaluation in FlowableException('Error while evaluating expression: <expr> with <variableContainer>'). This is the generic evaluation-failure path: anything other than PropertyNotFoundException/MethodNotFoundException lands here (e.g. NPE inside a bean method, ClassCastException, resolver errors).","triggerScenarios":"An expression whose evaluation throws at runtime — a method invoked in the expression throws an exception, a type coercion fails, an EL resolver (like JsonNodeELResolver) throws IllegalArgumentException/PropertyNotWritableException, etc.","commonSituations":"Bean methods invoked from expressions throwing NPE on unset fields; invoking JsonNodeELResolver-based writes on read-only resolvers; incompatible types in arithmetic/comparison inside the expression.","solutions":["Inspect the cause (getCause()) to find the real exception thrown during evaluation","Fix the underlying defect in the invoked bean method or expression types","Harden expressions against nulls (e.g. ${var != null && var.field != null ? ... : ...}) and avoid side effects in expressions"],"exampleFix":"// before\n${customer.address.city}  // NPE when address is null\n// after\n${customer.address != null ? customer.address.city : ''}","handlingStrategy":"try-catch","validationCode":"// pre-evaluate guarded version: ${v != null && v.field != null ? v.field : default}","typeGuard":"boolean safeChain(Object o, java.util.function.Function<Object,Object> f) { return o != null && java.util.Objects.nonNull(f.apply(o)); }","tryCatchPattern":"try { value = expr.getValue(ctx); } catch (FlowableException e) { Throwable root = e.getCause(); log.error(\"Expression {} failed: {}\", e.getMessage(), root, root); throw e; }","preventionTips":["Always inspect getCause() — the wrapped exception carries the real defect","Null-guard bean methods invoked from expressions","Keep expressions side-effect free and simple; move complex logic to delegates","Log expression text plus VariableContainer contents when evaluation fails"],"tags":["java","expression","evaluation","flowable"],"backgroundTag":"expression-evaluation-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}