{"record":{"id":"5486b36ac82fa8ca","repo":"flowable/flowable-engine","slug":"cannot-get-variable-value-for-jackson-2","errorCode":null,"errorMessage":"Cannot get variable value for jackson 2","messagePattern":"Cannot get variable value for jackson 2","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/Jackson2JsonObjectRestVariableConverter.java","lineNumber":48,"sourceCode":"    protected ObjectMapper objectMapper;\n\n    public Jackson2JsonObjectRestVariableConverter(ObjectMapper objectMapper) {\n        this.objectMapper = objectMapper;\n    }\n\n    @Override\n    public String getRestTypeName() {\n        return \"json\";\n    }\n\n    @Override\n    public Class<?> getVariableType() {\n        return JsonNode.class;\n    }\n\n    @Override\n    public Object getVariableValue(EngineRestVariable result) {\n        throw new UnsupportedOperationException(\"Cannot get variable value for jackson 2\");\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof JsonNode)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert com.fasterxml.jackson.databind.JsonNode.\");\n            }\n            tools.jackson.databind.JsonNode valueNode = objectMapper.readTree(variableValue.toString());\n            result.setValue(valueNode);\n        } else {\n            result.setValue(null);\n        }\n    }\n\n}\n","sourceCodeStart":30,"sourceCodeEnd":65,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/Jackson2JsonObjectRestVariableConverter.java#L30-L65","documentation":"Jackson2JsonObjectRestVariableConverter handles Flowable JSON variables backed by Jackson's JsonNode. Its getVariableValue is intentionally unimplemented: reading a JSON variable back from a REST representation is not supported for this converter, so it always throws UnsupportedOperationException with this message.","triggerScenarios":"Any REST call that resolves a variable whose REST type maps to the Jackson 2 JSON converter (getVariableType() returns JsonNode.class) and requires getVariableValue — i.e. reading a JSON-typed variable through the REST API.","commonSituations":"Fetching a process/task variable that was stored as a Flowable JsonNode JSON variable via the REST API; Flowable versions where JSON variable read-back was simply not wired up for Jackson 2.","solutions":["Do not read JSON variables through this converter; store them as plain strings and parse to JsonNode client-side.","Upgrade to a Flowable version where JSON variable conversion via REST is supported.","Provide a custom RestVariableConverter for JsonNode that implements getVariableValue by parsing result.getValue() with an ObjectMapper.","Change the variable's REST type to 'string' so the string converter handles the read."],"exampleFix":"// before\nJsonNode node = (JsonNode) runtimeService.getVariable(executionId, \"payload\"); // served via jackson2 REST converter -> throws\n// after\nString json = (String) runtimeService.getVariable(executionId, \"payload\");\nJsonNode node = new ObjectMapper().readTree(json);","handlingStrategy":"try-catch","validationCode":"public static boolean supportsJsonRead(RestVariableConverter c) {\n    try { c.getVariableValue(null); return false; } catch (UnsupportedOperationException e) { return false; } catch (Exception e) { return true; }\n}","typeGuard":"public static boolean isJacksonJsonConverter(RestVariableConverter c) { return c instanceof Jackson2JsonObjectRestVariableConverter; }","tryCatchPattern":"try {\n    Object value = restClient.getVariable(id, \"payload\");\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"Cannot get variable value for jackson 2\")) {\n        // read the variable as a string and parse to JsonNode locally\n    } else { throw e; }\n}","preventionTips":["Treat Jackson 2 JSON variables as write-only through the REST API in this version.","Store JSON as a plain string variable if you need REST read-back.","Register a custom RestVariableConverter with a working getVariableValue for JsonNode.","Check your Flowable version's REST JSON variable support before adopting the 'json' REST type."],"tags":["rest","json","jackson","unsupported","variable-converter"],"backgroundTag":"unsupported-operation","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}