{"record":{"id":"d6287024931f5214","repo":"flowable/flowable-engine","slug":"unexpected-exception-when-deserializing-jpa-id-s","errorCode":null,"errorMessage":"Unexpected exception when deserializing JPA id's","messagePattern":"Unexpected exception when deserializing JPA id's","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityListVariableType.java","lineNumber":168,"sourceCode":"            return baos.toByteArray();\n        } catch (IOException ioe) {\n            throw new FlowableException(\"Unexpected exception when serializing JPA id's\", ioe);\n        }\n    }\n\n    protected String[] deserializeIds(byte[] bytes) {\n        try {\n            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);\n            ObjectInputStream in = new ObjectInputStream(bais);\n\n            Object read = in.readObject();\n            if (!(read instanceof String[])) {\n                throw new FlowableIllegalArgumentException(\"Deserialized value is not an array of ID's: \" + read);\n            }\n\n            return (String[]) read;\n        } catch (IOException | ClassNotFoundException ioe) {\n            throw new FlowableException(\"Unexpected exception when deserializing JPA id's\", ioe);\n        }\n    }\n\n}\n","sourceCodeStart":150,"sourceCodeEnd":173,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JPAEntityListVariableType.java#L150-L173","documentation":"Companion to [4045]: after successfully deserializing, if the object is a String[] it is returned; if readObject itself throws IOException or ClassNotFoundException, Flowable rethrows this FlowableException ('Unexpected exception when deserializing JPA id's').","triggerScenarios":"deserializeIds called from ids() during getValue where ObjectInputStream.readObject fails — truncated/garbled byte array, or the serialized class cannot be found on the classpath (serialization of non-String objects in a customized build).","commonSituations":"Partial DB writes leaving truncated bytes; classpath differences between write and read nodes (custom ID classes removed during refactor); DB charset/encoding mishandling of binary columns.","solutions":["Check the wrapped cause: ClassNotFoundException means missing class on classpath — restore the class or migrate data","IOException usually means corrupt/truncated bytes — re-set the variable or fix the stored bytes","Use BLOB-safe transport for variable bytes (don't route binary data through text columns)","Pin serialization-compatible classes across cluster nodes"],"exampleFix":"// before\n// class refactor removed com.acme.CustomId used in old variables\n// after\n// keep a serializable legacy class or run a migration that rewrites variables to String ids","handlingStrategy":"try-catch","validationCode":"// ensure the serialized classes exist on this node's classpath\ntry { Class.forName(\"com.acme.CustomId\"); } catch (ClassNotFoundException e) { /* restore or migrate */ }","typeGuard":null,"tryCatchPattern":"try { Object v = runtimeService.getVariable(executionId, \"customers\"); } catch (FlowableException e) { if (e.getMessage().contains(\"deserializing JPA id\")) { Throwable c = e.getCause(); if (c instanceof ClassNotFoundException) { log.error(\"Missing class for stored variable\", c); } else { log.error(\"Corrupt variable bytes\", c); } } throw e; }","preventionTips":["Keep serialization-compatible classes available on all nodes (don't delete/refactor ID classes used in stored variables)","Use String IDs to avoid ClassNotFound risk","Validate binary variable columns survive transport (BLOB, not TEXT)"],"tags":["jpa","deserialization","classpath","flowable"],"backgroundTag":"class-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}