{"record":{"id":"1fe96edbd83fe113","repo":"apache/flink","slug":"could-not-load-the-typeinformation-for-the-class","errorCode":null,"errorMessage":"Could not load the TypeInformation for the class '{}'. You may be missing the 'flink-hadoop-compatibility' dependency.","messagePattern":"Could not load the TypeInformation for the class '(.+?)'\\. You may be missing the 'flink-hadoop-compatibility' dependency\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java","lineNumber":2461,"sourceCode":"        Class<?> superclass = clazz.getSuperclass();\n        return superclass != null\n                && alreadySeen.add(superclass)\n                && hasHadoopWritableInterface(superclass, alreadySeen);\n    }\n\n    // visible for testing\n    public static <T> TypeInformation<T> createHadoopWritableTypeInfo(Class<T> clazz) {\n        checkNotNull(clazz);\n\n        Class<?> typeInfoClass;\n        try {\n            typeInfoClass =\n                    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        }","sourceCodeStart":2443,"sourceCodeEnd":2479,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java#L2443-L2479","documentation":"Thrown by TypeExtractor.createHadoopWritableTypeInfo when trying to load the HadoopWritableTypeInfo class via Class.forName but the class is not found on the classpath. This means the flink-hadoop-compatibility module (which provides Writable type support) is not available as a dependency.","triggerScenarios":"Called during createHadoopWritableTypeInfo when a Hadoop Writable type is detected but the HADOOP_WRITABLE_TYPEINFO_CLASS constant (referencing org.apache.flink.hadoopcompatibility.wrappers.HadoopWritableTypeInfo) cannot be loaded via Class.forName with the context class loader. This happens when the flink-hadoop-compatibility JAR is missing from the classpath.","commonSituations":"Using Hadoop Writable types (e.g., Text, IntWritable, LongWritable) in Flink jobs without including the flink-hadoop-compatibility dependency. Running in environments where the classpath does not include all Flink modules (e.g., thin JARs, minimal Flink distributions). Version mismatches where the dependency exists but the class was moved or renamed.","solutions":["Add the flink-hadoop-compatibility dependency to your project (Maven/Gradle).","Ensure the dependency is shaded/bundled or available on the Flink cluster's lib directory.","Verify the Flink version matches between your project and the cluster to avoid class relocation issues.","If you don't need Hadoop Writable support, avoid using Writable types and convert to POJOs or Flink-native types."],"exampleFix":"// before (missing dependency)\n// pom.xml lacks flink-hadoop-compatibility\n\n// after\n// pom.xml\n<dependency>\n  <groupId>org.apache.flink</groupId>\n  <artifactId>flink-hadoop-compatibility_2.12</artifactId>\n  <version>${flink.version}</version>\n</dependency>","handlingStrategy":"try-catch","validationCode":"// Check if HadoopWritableTypeInfo is on the classpath before using Writable types\ntry {\n    Class.forName(\"org.apache.flink.hadoopcompatibility.wrappers.HadoopWritableTypeInfo\",\n        false, Thread.currentThread().getContextClassLoader());\n    // dependency present\n} catch (ClassNotFoundException e) {\n    // flink-hadoop-compatibility is missing; add it or avoid Writable types\n}","typeGuard":"static boolean hadoopCompatibilityAvailable() {\n    try {\n        Class.forName(\"org.apache.flink.hadoopcompatibility.wrappers.HadoopWritableTypeInfo\",\n            false, Thread.currentThread().getContextClassLoader());\n        return true;\n    } catch (ClassNotFoundException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    TypeInformation<?> ti = TypeExtractor.createHadoopWritableTypeInfo(MyWritable.class);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"flink-hadoop-compatibility\")) {\n        // add dependency or switch to non-Writable type\n        ti = TypeInformation.of(MyPojo.class);\n    } else throw e;\n}","preventionTips":["Add flink-hadoop-compatibility to your project dependencies when using Writable types.","Verify cluster classpath includes all required Flink modules.","Consider converting Writable types to Flink-native types (POJO, Row) if Hadoop compatibility is optional."],"tags":["hadoop","writable","missing-dependency","classpath"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}