{"record":{"id":"1b9383c5376db917","repo":"apache/hadoop","slug":"f-is-a-directory","errorCode":null,"errorMessage":"f + \" is a directory\"","messagePattern":"f \\+ \" is a directory\"","errorType":"exception","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java","lineNumber":189,"sourceCode":"        FileStatus result = stats[i++];\n        BlockLocation[] locs = result.isFile()\n            ? getFileBlockLocations(result, 0, result.getLen())\n            : null;\n        return new LocatedFileStatus(result, locs);\n      }\n    };\n  }\n\n  @Override\n  public FSDataOutputStream create(Path f, FsPermission permission,\n      boolean overwrite, int bufferSize, short replication,\n      long blockSize, Progressable progress) throws IOException {\n    Path absolutePath = makeAbsolute(f);\n    String key = pathToKey(absolutePath);\n\n    if (overwrite) {\n      if (store.isDirectory(key)) {\n        throw new FileAlreadyExistsException(\n            f + \" is a directory\");\n      }\n    } else {\n      try {\n        getFileStatus(f);\n        throw new FileAlreadyExistsException(\n            f + \" already exists\");\n      } catch (FileNotFoundException e) {\n        // nothing, ok\n      }\n    }\n\n    return new FSDataOutputStream(\n        store.createFile(key, getConf()), statistics);\n  }\n\n  /**\n   * Create a file non-recursively. The parent directory must","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java#L171-L207","documentation":"The new-mapreduce-API StreamInputFormat (org.apache.hadoop.streaming.mapreduce) reads stream.recordreader.class and resolves it with StreamUtil.goodClassOrNull(conf, c, null) — note the null defaultPackage, so no package prefix is ever appended. If the class cannot be loaded by name it throws RuntimeException 'Class not found'. This guards the factory dispatch that instantiates non-standard record readers such as the mapreduce StreamXmlRecordReader.","triggerScenarios":"Setting stream.recordreader.class (via -inputreader ...) to a class missing from the task classpath, or to a bare short name like 'StreamXmlRecordReader' — because defaultPackage is null, the unqualified name is never resolved to org.apache.hadoop.streaming.mapreduce.StreamXmlRecordReader.","commonSituations":"Streaming jobs using the mapreduce API path with -inputreader; typos in the fully-qualified class name; custom record reader jar not shipped with -libjars so ClassNotFoundException is swallowed by goodClassOrNull and resurfaces as this RuntimeException.","solutions":["Use the fully-qualified name: -inputreader org.apache.hadoop.streaming.mapreduce.StreamXmlRecordReader (short names do not work here because no default package is applied).","Fix typos/dotted-path mistakes in the stream.recordreader.class value; verify the class exists with `hadoop classpath` + javap or a local Class.forName test.","If the reader is your own, ship its jar with -libjars (or package it inside the job jar) so the task classloader can find it.","For standard line-based input, remove -inputreader entirely; StreamInputFormat delegates to KeyValueTextInputFormat when the class name contains 'LineRecordReader' or is unset."],"exampleFix":"# before\n-inputreader StreamXmlRecordReader   # unqualified -> 'Class not found: StreamXmlRecordReader'\n\n# after\n-inputreader org.apache.hadoop.streaming.mapreduce.StreamXmlRecordReader","handlingStrategy":"validation","validationCode":"String c = conf.get(\"stream.recordreader.class\");\nif (c != null && StreamUtil.goodClassOrNull(conf, c, null) == null) {\n  throw new IllegalArgumentException(\n      \"stream.recordreader.class not loadable (use FQCN, add jar to classpath): \" + c);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use the fully-qualified class name with -inputreader on the mapreduce path (no default package is applied).","Ship custom reader jars with -libjars.","Smoke-test Class.forName on the task classpath before submitting."],"tags":["hadoop","streaming","class-not-found","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"}