{"record":{"id":"c1debbbf7083a638","repo":"apache/flink","slug":"incompatible-versions-of-the-hadoop-compatibility","errorCode":null,"errorMessage":"Incompatible versions of the Hadoop Compatibility classes found.","messagePattern":"Incompatible versions of the Hadoop Compatibility classes found\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java","lineNumber":2474,"sourceCode":"                    Class.forName(\n                            HADOOP_WRITABLE_TYPEINFO_CLASS,\n                            false,\n                            Thread.currentThread().getContextClassLoader());\n        } catch (ClassNotFoundException e) {\n            throw new RuntimeException(\n                    \"Could not load the TypeInformation for the class '\"\n                            + HADOOP_WRITABLE_CLASS\n                            + \"'. You may be missing the 'flink-hadoop-compatibility' dependency.\");\n        }\n\n        try {\n            Constructor<?> constr = typeInfoClass.getConstructor(Class.class);\n\n            @SuppressWarnings(\"unchecked\")\n            TypeInformation<T> typeInfo = (TypeInformation<T>) constr.newInstance(clazz);\n            return typeInfo;\n        } catch (NoSuchMethodException | IllegalAccessException | InstantiationException e) {\n            throw new RuntimeException(\n                    \"Incompatible versions of the Hadoop Compatibility classes found.\");\n        } catch (InvocationTargetException e) {\n            throw new RuntimeException(\n                    \"Cannot create Hadoop WritableTypeInfo.\", e.getTargetException());\n        }\n    }\n\n    // visible for testing\n    static void validateIfWritable(TypeInformation<?> typeInfo, Type type) {\n        try {\n            // try to load the writable type info\n\n            Class<?> writableTypeInfoClass =\n                    Class.forName(\n                            HADOOP_WRITABLE_TYPEINFO_CLASS,\n                            false,\n                            typeInfo.getClass().getClassLoader());\n","sourceCodeStart":2456,"sourceCodeEnd":2492,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L2456-L2492","documentation":"Thrown by TypeExtractor.createHadoopWritableTypeInfo when the HadoopWritableTypeInfo class is found on the classpath but its constructor cannot be invoked — the expected constructor HadoopWritableTypeInfo(Class) is missing, inaccessible, or the class cannot be instantiated. This indicates an incompatible version of flink-hadoop-compatibility.","triggerScenarios":"Called during createHadoopWritableTypeInfo after successfully loading HadoopWritableTypeInfo, but typeInfoClass.getConstructor(Class.class).newInstance(clazz) throws NoSuchMethodException, IllegalAccessException, or InstantiationException. This means the loaded version of the class has a different API than expected.","commonSituations":"Mixing Flink versions (e.g., core from 1.18 but hadoop-compatibility from 1.15). The HadoopWritableTypeInfo class changed its constructor signature between versions. Classloader isolation issues where a different/incompatible version is loaded by a parent classloader. Shading/dependency conflicts where multiple versions are on the classpath.","solutions":["Ensure all Flink modules use the same version (align flink-core and flink-hadoop-compatibility versions in pom.xml/gradle).","Run mvn dependency:tree to find and exclude conflicting transitive versions of flink-hadoop-compatibility.","Use the Flink Maven dependency enforcer or BOM to keep versions consistent.","If shading, ensure shading rules don't relocate internal Flink classes incompatibly."],"exampleFix":"// before\n<dependency>\n  <groupId>org.apache.flink</groupId>\n  <artifactId>flink-core</artifactId>\n  <version>1.18.0</version>\n</dependency>\n<dependency>\n  <groupId>org.apache.flink</groupId>\n  <artifactId>flink-hadoop-compatibility_2.12</artifactId>\n  <version>1.15.0</version> <!-- mismatched! -->\n</dependency>\n\n// after (aligned versions)\n<dependency>\n  <groupId>org.apache.flink</groupId>\n  <artifactId>flink-hadoop-compatibility_2.12</artifactId>\n  <version>1.18.0</version>\n</dependency>","handlingStrategy":"try-catch","validationCode":"// Verify the constructor exists and is accessible\nClass<?> cls = Class.forName(\"org.apache.flink.hadoopcompatibility.wrappers.HadoopWritableTypeInfo\");\ntry {\n    cls.getConstructor(Class.class);\n    // compatible version\n} catch (NoSuchMethodException e) {\n    // incompatible version; align Flink versions\n}","typeGuard":"static boolean hadoopWritableTypeInfoCompatible() {\n    try {\n        Class<?> cls = Class.forName(\n            \"org.apache.flink.hadoopcompatibility.wrappers.HadoopWritableTypeInfo\");\n        cls.getConstructor(Class.class);\n        return true;\n    } catch (Exception e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    TypeInformation<?> ti = TypeExtractor.createHadoopWritableTypeInfo(MyWritable.class);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"Incompatible versions\")) {\n        // align all Flink module versions\n    } else throw e;\n}","preventionTips":["Keep all Flink module versions aligned (use BOM or enforcer plugin).","Run mvn dependency:tree to detect conflicting flink-hadoop-compatibility versions.","Avoid mixing Flink versions across modules."],"tags":["hadoop","writable","version-mismatch","classpath"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}