{"record":{"id":"c1c37519daca1568","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-value-for-expression-expression-with-ognl","errorCode":null,"errorMessage":"Unable to get value for expression [<expression>] with Ognl","messagePattern":"Unable to get value for expression \\[<expression>\\] with Ognl","errorType":"exception","errorClass":"KettleConfigException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/config/PropertySetter.java","lineNumber":103,"sourceCode":"    if ( expression.length >= 2 ) {\n      OgnlExpression expr = ognlExpressions.get( value );\n      if ( expr == null ) {\n        synchronized ( ognlExpressions ) {\n          try {\n            expr = new OgnlExpression( expression[1] );\n            ognlExpressions.put( value, expr );\n\n          } catch ( OgnlException e ) {\n            throw new KettleConfigException( \"Unable to parse expression [\" + expression[1] + \"] with Ognl\", e );\n          }\n        }\n      }\n\n      // evaluate\n      try {\n        return expr.getValue( octx, this );\n      } catch ( OgnlException e ) {\n        throw new KettleConfigException(\n          \"Unable to get value for expression [\" + expression[1] + \"] with Ognl\", e );\n      }\n    } else {\n      throw new KettleConfigException(\n        \"the ognl, directive need at least 2 parameters: ongl and the expression but \"\n          + expression.length + \" parameters were found in [\" + value + \"]\" );\n    }\n  }\n}\n","sourceCodeStart":85,"sourceCodeEnd":113,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/config/PropertySetter.java#L85-L113","documentation":"After successfully compiling an OGNL expression, setOgnlProperty evaluates it via expr.getValue(ognlContext, this). This error is thrown when the expression is syntactically valid but fails during evaluation (OgnlException at getValue time), e.g. it references a null object, an inaccessible method, or a nonexistent property on the target.","triggerScenarios":"setProperty(obj, property, \"ognl:objRef.someMethod()\") where evaluation throws — invoking a method on null, calling a missing method, or triggering an exception inside the OGNL navigation chain.","commonSituations":"OGNL expressions referencing properties that are null at config-apply time; expressions written against an older object model whose getters no longer exist; security-restricted method invocation failures at runtime.","solutions":["Fix the expression so it only navigates non-null, existing properties/methods of the target object.","Add null-safe navigation in the OGNL expression where supported, or ensure the target object is fully initialized before setProperty runs.","Test the same expression with ognl.Ognl.getValue(expr, context, target) outside the config pipeline to reproduce and debug.","Catch KettleConfigException around config application and log the expression plus target object state."],"exampleFix":"// before\npropertySetter.setProperty(obj, \"dir\", \"ognl:user.homeDir.path\"); // homeDir may be null\n\n// after\npropertySetter.setProperty(obj, \"dir\", \"ognl:user.homeDir != null ? user.homeDir.path : '/tmp'\");","handlingStrategy":"try-catch","validationCode":"Object probe = org.apache.commons.ognl.Ognl.getValue(\n  org.apache.commons.ognl.Ognl.parseExpression(expr), ctx, target); // fails fast outside config load","typeGuard":null,"tryCatchPattern":"try {\n  propertySetter.setProperty(obj, property, \"ognl:\" + expr);\n} catch (KettleConfigException e) {\n  LOG.error(\"OGNL evaluation failed for expression [\" + expr + \"] on \" + obj.getClass(), e);\n}","preventionTips":["Ensure referenced getters exist and are public on the target object.","Guard OGNL navigation chains against nulls.","Re-validate expressions after refactoring the target object model."],"tags":["config","ognl","expression-evaluation"],"backgroundTag":"evaluation-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}