{"record":{"id":"292c88b3b8a85e51","repo":"apache/hadoop","slug":"class-not-found-292c88","errorCode":null,"errorMessage":"Class not found: {}","messagePattern":"Class not found: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/streaming/StreamInputFormat.java","lineNumber":60,"sourceCode":"      return super.getRecordReader(genericSplit, job, reporter);\n    }\n\n    // handling non-standard record reader (likely StreamXmlRecordReader) \n    FileSplit split = (FileSplit) genericSplit;\n    LOG.info(\"getRecordReader start.....split=\" + split);\n    reporter.setStatus(split.toString());\n\n    // Open the file and seek to the start of the split\n    FileSystem fs = split.getPath().getFileSystem(job);\n    FSDataInputStream in = fs.open(split.getPath());\n\n    // Factory dispatch based on available params..\n    Class readerClass;\n\n    {\n      readerClass = StreamUtil.goodClassOrNull(job, c, null);\n      if (readerClass == null) {\n        throw new RuntimeException(\"Class not found: \" + c);\n      }\n    }\n\n    Constructor ctor;\n    try {\n      ctor = readerClass.getConstructor(new Class[] { FSDataInputStream.class,\n                                                      FileSplit.class, Reporter.class, JobConf.class, FileSystem.class });\n    } catch (NoSuchMethodException nsm) {\n      throw new RuntimeException(nsm);\n    }\n\n    RecordReader<Text, Text> reader;\n    try {\n      reader = (RecordReader<Text, Text>) ctor.newInstance(new Object[] { in, split,\n                                                              reporter, job, fs });\n    } catch (Exception nsm) {\n      throw new RuntimeException(nsm);\n    }","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/streaming/StreamInputFormat.java#L42-L78","documentation":"StreamInputFormat.getRecordReader() loads the class named by the job property stream.recordreader.class (used for non-standard readers such as StreamXmlRecordReader) via StreamUtil.goodClassOrNull(). If the class cannot be loaded from the job classpath, it returns null and the code throws RuntimeException 'Class not found: <classname>'. The next failure mode after this (NoSuchMethodException wrapper) requires a constructor (FSDataInputStream, FileSplit, Reporter, JobConf, FileSystem).","triggerScenarios":"Setting stream.recordreader.class (typically -D stream.recordreader.class=org.apache.hadoop.streaming.StreamXmlRecordReader or a custom reader) to a class that is not on the task classpath: typo in the FQCN, jar not shipped via -libjars/-files, or custom reader compiled against a different version.","commonSituations":"Custom record readers developed out-of-tree and forgotten in the submit command, package renames between versions, case-sensitive class names mistyped on the command line, or the jar present on the client but never shipped to task nodes.","solutions":["Ship the reader's jar with the job: -libjars myreaders.jar (and ensure nodes can resolve it) or place it on the cluster-wide classpath","Verify the fully-qualified class name spelling, package and case exactly match the compiled class","Check the class has a public constructor (FSDataInputStream, FileSplit, Reporter, JobConf, FileSystem) or it will fail the next check","For XML input, use the bundled org.apache.hadoop.streaming.StreamXmlRecordReader with -inputreader StreamXmlRecordReader instead of a hand-rolled class"],"exampleFix":"# before\nhadoop jar hadoop-streaming.jar -input in -output out \\\n  -D stream.recordreader.class=com.myco.MyXmlReader -mapper cat\n# after: ship the jar containing the reader\nhadoop jar hadoop-streaming.jar -input in -output out \\\n  -libjars myxmlreader.jar \\\n  -D stream.recordreader.class=com.myco.MyXmlReader -mapper cat","handlingStrategy":"validation","validationCode":"// before submitting: resolve exactly like StreamInputFormat will\nClass<?> c = StreamUtil.goodClassOrNull(jobConf, \"com.myco.MyXmlReader\", null);\nif (c == null) throw new IllegalStateException(\"stream.recordreader.class not loadable — add jar via -libjars\");\ntry {\n  c.getConstructor(FSDataInputStream.class, FileSplit.class, Reporter.class, JobConf.class, FileSystem.class);\n} catch (NoSuchMethodException e) { throw new IllegalStateException(\"reader lacks required constructor\", e); }","typeGuard":null,"tryCatchPattern":"catch RuntimeException from job run; if the message is 'Class not found: X', fix classpath/ship the jar — no retry helps until the class resolves.","preventionTips":["Always pass custom reader jars with -libjars (or cluster classpath) at submission","Copy FQCNs from the jar itself (javap/unzip -l) rather than typing from memory","Verify the required 5-arg constructor exists in custom readers","Prefer built-in StreamXmlRecordReader for XML inputs"],"tags":["hadoop-streaming","classpath","classloading","record-reader","configuration"],"backgroundTag":"class-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}