{"record":{"id":"6d6cbee95bddad8c","repo":"juicedata/juicefs","slug":"cannot-load-default-config","errorCode":null,"errorMessage":"Cannot load default config","messagePattern":"Cannot load default config","errorType":"exception","errorClass":"DatasetIOException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/KiteDataLoader.java","lineNumber":60,"sourceCode":"      try {\n        fs = FileSystem.get(fileSystemURI(match), conf);\n      } catch (IOException e) {\n        throw new DatasetIOException(\"Could not get a FileSystem\", e);\n      }\n      return new FileSystemDatasetRepository.Builder()\n              .configuration(new Configuration(conf)) // make a modifiable copy\n              .rootDirectory(fs.makeQualified(root))\n              .build();\n    }\n  }\n\n  @Override\n  public void load() {\n    try {\n      // load hdfs-site.xml by loading HdfsConfiguration\n      FileSystem.getLocal(DefaultConfiguration.get());\n    } catch (IOException e) {\n      throw new DatasetIOException(\"Cannot load default config\", e);\n    }\n\n    OptionBuilder<DatasetRepository> builder = new URIBuilder();\n    Registration.register(\n            new URIPattern(\"jfs:/*path\"),\n            new URIPattern(\"jfs:/*path/:namespace/:dataset\"),\n            builder);\n  }\n\n  private static URI fileSystemURI(Map<String, String> match) {\n    try {\n      return new URI(match.get(URIPattern.SCHEME), null,\n              match.get(URIPattern.HOST), -1, \"/\", null, null);\n    } catch (URISyntaxException ex) {\n      throw new DatasetOperationException(\"[BUG] Could not build FS URI\", ex);\n    }\n  }\n}","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/KiteDataLoader.java#L42-L78","documentation":"In load(), KiteDataLoader calls FileSystem.getLocal(DefaultConfiguration.get()) purely to force eager loading of the default Hadoop configuration (including hdfs-site.xml). If that throws IOException, it wraps it in DatasetIOException with this message. The getLocal call is a config-validation probe, so failure means the Hadoop configuration could not be loaded at all.","triggerScenarios":"Calling KiteDataLoader.load() when HADOOP_CONF_DIR/HADOOP_HOME point to missing or unreadable config directories, or when loading hdfs-site.xml/core-site.xml throws an IOException (parse/IO error), making DefaultConfiguration.get() or FileSystem.getLocal fail.","commonSituations":"Deploying the JuiceFS/Kite loader in a container or Spark job without the Hadoop conf directory mounted; malformed XML in core-site.xml/hdfs-site.xml; HADOOP_CONF_DIR unset so defaults are absent.","solutions":["Ensure HADOOP_CONF_DIR (and HADOOP_HOME) point to a directory containing valid core-site.xml/hdfs-site.xml in the runtime environment.","Inspect the wrapped IOException cause for the exact file that failed to load and repair its syntax/permissions.","If embedding programmatically, pre-load Configuration.addDefaultResource or set config paths before calling load().","Confirm the hadoop-common jar is on the classpath so FileSystem.getLocal can instantiate LocalFileSystem."],"exampleFix":"// before: app launched with no conf -> DatasetIOException: Cannot load default config\n// after\nexport HADOOP_CONF_DIR=/etc/hadoop/conf\nspark-submit --driver-class-path $HADOOP_CONF_DIR ...","handlingStrategy":"validation","validationCode":"String confDir = System.getenv(\"HADOOP_CONF_DIR\");\nif (confDir == null || !new java.io.File(confDir, \"core-site.xml\").canRead()) {\n  throw new IllegalStateException(\"HADOOP_CONF_DIR missing or unreadable: \" + confDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n  loader.load();\n} catch (DatasetIOException e) {\n  throw new IllegalStateException(\"Hadoop default config failed to load: \" + e.getCause().getMessage(), e);\n}","preventionTips":["Set HADOOP_CONF_DIR in container images and job launch scripts.","Validate XML config files after edits (xmllint) before deploying.","Load Configuration once at app startup and fail fast there."],"tags":["java","hadoop","configuration","environment"],"backgroundTag":"missing-config-file","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}