{"record":{"id":"51a5bcba13a9ab02","repo":"flowable/flowable-engine","slug":"error-getting-variable-variablename","errorCode":null,"errorMessage":"Error getting variable \" + variableName","messagePattern":"Error getting variable \" \\+ variableName","errorType":"http","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/BaseExecutionVariableResource.java","lineNumber":98,"sourceCode":"            if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {\n                result = (byte[]) variable.getValue();\n                response.setContentType(\"application/octet-stream\");\n\n            } else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {\n                try (ByteArrayOutputStream buffer = new ByteArrayOutputStream();\n                     ObjectOutputStream outputStream = new ObjectOutputStream(buffer)) {\n                    outputStream.writeObject(variable.getValue());\n                    result = buffer.toByteArray();\n                    response.setContentType(\"application/x-java-serialized-object\");\n                }\n\n            } else {\n                throw new FlowableObjectNotFoundException(\"The variable does not have a binary data stream.\", null);\n            }\n            return result;\n\n        } catch (IOException ioe) {\n            throw new FlowableException(\"Error getting variable \" + variableName, ioe);\n        }\n    }\n\n    protected RestVariable setBinaryVariable(MultipartHttpServletRequest request, Execution execution, boolean isNew, boolean async) {\n\n        // Validate input and set defaults\n        if (request.getFileMap().size() == 0) {\n            throw new FlowableIllegalArgumentException(\"No file content was found in request body.\");\n        }\n\n        // Get first file in the map, ignore possible other files\n        MultipartFile file = request.getFile(request.getFileMap().keySet().iterator().next());\n\n        if (file == null) {\n            throw new FlowableIllegalArgumentException(\"No file content was found in request body.\");\n        }\n\n        String variableScope = null;","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/BaseExecutionVariableResource.java#L80-L116","documentation":"FlowableException wrapping an IOException thrown while producing the binary representation of an execution variable in the REST API. Serialization of the variable value (writeObject/toByteArray) failed at the I/O level; the variableName is included in the message and the IOException is the cause.","triggerScenarios":"GET on an execution variable data endpoint where the variable value is serializable and ObjectOutputStream.writeObject or ByteArrayOutputStream.toByteArray throws IOException during response preparation.","commonSituations":"Non-serializable or broken object stored as a 'serializable' variable; JVM serialization version mismatch between stored data and current classes; storage I/O errors.","solutions":["Read the wrapped IOException cause to identify the serialization failure","Re-save the variable with a byte-array (binary) type instead of serializable object","Ensure classes stored in serializable variables exist and share serialVersionUID across deployments","Upgrade Flowable if the failure stems from a known stream-handling bug"],"exampleFix":"// before\nruntimeService.setVariable(executionId, name, someNonSerializableObject);\n// after\nruntimeService.setVariable(executionId, name,\n    SerializeUtil.serializeToBytes(someSerializableObject)); // store as binary","handlingStrategy":"try-catch","validationCode":"Object value = variable.getValue();\nif (value != null && !(value instanceof java.io.Serializable)) {\n    throw new IllegalStateException(\"value must be Serializable to store as serializable variable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    byte[] data = client.getVariableData(executionId, name);\n} catch (FlowableException | HttpServerErrorException e) {\n    log.error(\"serialization failure for variable \" + name, e.getCause());\n}","preventionTips":["Store only Serializable classes with stable serialVersionUID in serializable variables","Prefer binary (byte[]) variables for portable payloads","Keep server and client class versions in sync"],"tags":["io","serialization","rest-api","variables"],"backgroundTag":"file-read-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"}