{"record":{"id":"c38ed27d058c41e6","repo":"apache/flink","slug":"the-accumulator-object-name-was-created-with-t-c38ed2","errorCode":null,"errorMessage":"The accumulator object '{name}' was created with two different classes: {first} and {second} Both have the same type ({first.getName()}) but different classloaders: {first.getClassLoader()} and {second.getClassLoader()}","messagePattern":"The accumulator object '(.+?)' was created with two different classes: (.+?) and (.+?) Both have the same type \\((.+?)\\) but different classloaders: (.+?) and (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/accumulators/AccumulatorHelper.java","lineNumber":113,"sourceCode":"    public static void compareAccumulatorTypes(\n            Object name, Class<? extends Accumulator> first, Class<? extends Accumulator> second)\n            throws UnsupportedOperationException {\n        if (first == null || second == null) {\n            throw new NullPointerException();\n        }\n\n        if (first != second) {\n            if (!first.getName().equals(second.getName())) {\n                throw new UnsupportedOperationException(\n                        \"The accumulator object '\"\n                                + name\n                                + \"' was created with two different types: \"\n                                + first.getName()\n                                + \" and \"\n                                + second.getName());\n            } else {\n                // damn, name is the same, but different classloaders\n                throw new UnsupportedOperationException(\n                        \"The accumulator object '\"\n                                + name\n                                + \"' was created with two different classes: \"\n                                + first\n                                + \" and \"\n                                + second\n                                + \" Both have the same type (\"\n                                + first.getName()\n                                + \") but different classloaders: \"\n                                + first.getClassLoader()\n                                + \" and \"\n                                + second.getClassLoader());\n            }\n        }\n    }\n\n    /** Transform the Map with accumulators into a Map containing only the results. */\n    public static Map<String, OptionalFailure<Object>> toResultMap(","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/accumulators/AccumulatorHelper.java#L95-L131","documentation":"Thrown by AccumulatorHelper.compareAccumulatorTypes when two accumulators share a name and have the same fully-qualified class name, but were loaded by different ClassLoaders. Same name + same class but different loader means the JVM treats them as distinct types and they cannot be merged. This is a classloader-isolation symptom, not a programming typo.","triggerScenarios":"User-function jars loaded by different classloaders each registering the same accumulator class; the table-planner child classloader vs the user-code classloader both contributing accumulator results; UDFs packaged in nested jars loaded via the user-code classloader mechanism.","commonSituations":"Running with the planner in a child classloader (flink-table-planner-loader) where accumulator classes leak across the boundary; bundling Flink dependencies inside the user jar (fat-jar) causing duplicate class copies; library conflicts between connector jars and the dist.","solutions":["Do not bundle flink runtime/accumulator classes inside your user jar; mark them as provided scope.","Ensure the accumulator class is loaded by a single classloader — put it in the user-jar only, or in lib/ only, not both.","If using the planner, avoid registering custom accumulator types across the planner/user boundary."],"exampleFix":"// before (pom.xml - bundles flink classes into fat jar)\n<dependency>\n  <groupId>org.apache.flink</groupId>\n  <artifactId>flink-runtime</artifactId>\n</dependency>\n// after\n<dependency>\n  <groupId>org.apache.flink</groupId>\n  <artifactId>flink-runtime</artifactId>\n  <scope>provided</scope>\n</dependency>","handlingStrategy":"validation","validationCode":"// ensure flink deps are 'provided' in the user jar\n// <scope>provided</scope> on flink-runtime, flink-core, etc.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mark Flink dependencies as 'provided' scope in your pom.","Don't bundle flink-runtime/flink-core into fat jars.","Keep accumulator classes in exactly one classloader."],"tags":["accumulator","classloader","isolation","fat-jar"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}