{"record":{"id":"936e5cc2662c4127","repo":"flowable/flowable-engine","slug":"error-getting-variable-variable-getname","errorCode":null,"errorMessage":"Error getting variable ${variable.getName()}","messagePattern":"Error getting variable (.+?)","errorType":"http","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java","lineNumber":163,"sourceCode":"        byte[] result = null;\n        try {\n            if (CmmnRestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {\n                result = (byte[]) variable.getValue();\n                response.setContentType(\"application/octet-stream\");\n\n            } else if (CmmnRestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {\n                ByteArrayOutputStream buffer = new ByteArrayOutputStream();\n                ObjectOutputStream outputStream = new ObjectOutputStream(buffer);\n                outputStream.writeObject(variable.getValue());\n                outputStream.close();\n                result = buffer.toByteArray();\n                response.setContentType(\"application/x-java-serialized-object\");\n\n            } else {\n                throw new FlowableObjectNotFoundException(\"The variable does not have a binary data stream.\", null);\n            }\n        } catch (IOException ioe) {\n            throw new FlowableException(\"Error getting variable \" + variable.getName(), ioe);\n        }\n        return result;\n    }\n\n    protected RestVariable constructRestVariable(String variableName, Object value, String caseInstanceId, int variableType, boolean includeBinary,\n            RestVariableScope scope) {\n        return restResponseFactory.createRestVariable(variableName, value, scope, caseInstanceId, variableType, includeBinary);\n    }\n\n    protected List<RestVariable> processCaseVariables(CaseInstance caseInstance) {\n\n        // Check if it's a valid execution to get the variables for\n        List<RestVariable> variables = addVariables(caseInstance);\n\n        // Get unique variables from map\n        List<RestVariable> result = new ArrayList<>(variables);\n        return result;\n    }","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java#L145-L181","documentation":"Generic FlowableException wrapper thrown when an IOException occurs while serializing the variable value to a byte stream in restVariableDataToRestResponse. It is not a client error per se; it indicates the server failed to read/serialize the variable's binary data.","triggerScenarios":"GET .../variables/{name}/data on a serializable variable whose object cannot be written to ObjectOutputStream (non-serializable class, serialization version mismatch, corrupted stored bytes).","commonSituations":"A stored Java object's class was changed/redeployed with a different serialVersionUID; the value was stored by an older Flowable version; custom classes no longer on the server classpath.","solutions":["Inspect the wrapped IOException cause to identify serialization incompatibility (e.g. serialVersionUID mismatch or ClassNotFoundException).","Ensure the variable value's class exists on the server classpath with a stable serialVersionUID.","Delete and re-set the variable with a binary or JSON value instead of a Java-serialized object.","Prefer 'binary' variables over 'serializable' to avoid class-versioning issues."],"exampleFix":"// before\nclass OrderPayload implements Serializable { /* no serialVersionUID, class changed */ }\n// after\nclass OrderPayload implements Serializable {\n    private static final long serialVersionUID = 1L;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return getVariableData(id, name);\n} catch (FlowableException e) {\n  log.error(\"Variable {} data read failed: {}\", name, e.getCause(), e);\n  throw new ApiException(\"Variable data unreadable, re-upload the variable\", e);\n}","preventionTips":["Give every Serializable payload class an explicit fixed serialVersionUID.","Keep payload classes on the server classpath across deployments.","Prefer 'binary' variables over Java-serialized 'serializable' values for long-lived data."],"tags":["rest","serialization","variables","io"],"backgroundTag":"json-serialization-failed","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"}