{"record":{"id":"a315e8e38cefbeed","repo":"apache/flink","slug":"could-not-load-deserializer-from-the-configuration","errorCode":null,"errorMessage":"Could not load deserializer from the configuration.","messagePattern":"Could not load deserializer from the configuration\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java","lineNumber":76,"sourceCode":"        } catch (Exception e) {\n            throw new RuntimeException(\"Could not serialize serializer into the configuration.\", e);\n        }\n    }\n\n    @Override\n    public void readParametersFromConfig(Configuration config, ClassLoader cl)\n            throws ClassNotFoundException {\n        if (config == null || cl == null) {\n            throw new NullPointerException();\n        }\n\n        try {\n            this.clazz = InstantiationUtil.readObjectFromConfig(config, CONFIG_KEY_CLASS, cl);\n            this.serializer = InstantiationUtil.readObjectFromConfig(config, CONFIG_KEY_SER, cl);\n        } catch (ClassNotFoundException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new RuntimeException(\"Could not load deserializer from the configuration.\", e);\n        }\n    }\n\n    @Override\n    public TypeSerializer<T> getSerializer() {\n        if (this.serializer != null) {\n            return this.serializer.duplicate();\n        } else {\n            throw new RuntimeException(\n                    \"SerializerFactory has not been initialized from configuration.\");\n        }\n    }\n\n    @Override\n    public Class<T> getDataType() {\n        return clazz;\n    }\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java#L58-L94","documentation":"RuntimeSerializerFactory.readParametersFromConfig re-reads the stored class and serializer objects from the Configuration on the cluster side. This error covers any deserialization failure other than ClassNotFoundException (which is rethrown as-is): corrupted byte stream, incompatible class versions, or a failing custom readObject in the serializer.","triggerScenarios":"TaskManager reads CONFIG_KEY_CLASS/CONFIG_KEY_SER and ObjectInputStream fails with InvalidClassException (serialVersionUID mismatch), StreamCorruptedException, or the serializer's readObject throws a RuntimeException. Happens when the user jar on the TaskManager differs from the client's, or the Configuration was carried over from an incompatible run.","commonSituations":"Cluster running an older user jar while the client submits with a newer serializer class (or vice versa). Adding serialVersionUID after jobs were serialized. Serializer state whose custom readObject depends on resources unavailable at deserialization time (e.g. opens a file).","solutions":["Read the 'Caused by' chain: InvalidClassException(local class incompatible) means version skew -> align user jars on client and all TaskManagers.","Add an explicit private static final long serialVersionUID to the custom serializer so benign refactors do not break compatibility.","Make custom readObject defensive: no I/O or external resource access during deserialization; lazy-initialize instead.","Do not persist/reuse Configuration blobs across jobs; write and read them within one submission cycle."],"exampleFix":"// before\npublic class MySer extends TypeSerializer<MyPojo> implements Serializable {\n    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {\n        in.defaultReadObject();\n        this.schema = RegistryClient.load(); // throws on TM -> 684\n    }\n}\n\n// after\npublic class MySer extends TypeSerializer<MyPojo> implements Serializable {\n    private static final long serialVersionUID = 1L;\n    private transient Schema schema;\n    private Schema schema() { if (schema == null) schema = RegistryClient.load(); return schema; }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    factory.readParametersFromConfig(config, cl);\n} catch (ClassNotFoundException e) {\n    // rethrown as-is: missing class in user jar\n} catch (RuntimeException e) {\n    // InvalidClassException/StreamCorruptedException in cause: version skew or corruption\n    if (e.getCause() instanceof java.io.InvalidClassException) { /* realign user jars */ }\n    throw e;\n}","preventionTips":["Pin serialVersionUID on custom serializers before first deployment.","Keep client and TaskManager user jars byte-identical (CI checksum check).","Keep custom readObject side-effect free; lazy-initialize resources after deserialization."],"tags":["serialization","deserialization","version-mismatch","classloader"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}