{"record":{"id":"89d51f5fddc1998d","repo":"juicedata/juicefs","slug":"hadoop-version-was-incompatible-current-hadoop-ve","errorCode":null,"errorMessage":"Hadoop version was incompatible, current hadoop version is:\\t\" + VersionInfo.getVersion()","messagePattern":"Hadoop version was incompatible, current hadoop version is:\\\\t\" \\+ VersionInfo\\.getVersion\\(\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java","lineNumber":738,"sourceCode":"  private void updateUidAndGrouping(String uidFile, String groupFile) throws IOException {\n    String uidstr = parseUidAndGrouping(USERNAME_UID_PATTERN, uidFile);\n    if (uidstr == null && uidFile != null && !\"\".equals(uidFile.trim())) {\n      uidstr = readFile(uidFile);\n    }\n    String grouping = parseUidAndGrouping(GROUPNAME_GID_USERNAMES_PATTERN, groupFile);\n    if (grouping == null && groupFile != null && !\"\".equals(groupFile.trim())) {\n      grouping = readFile(groupFile);\n    }\n\n    lib.jfs_update_uid_grouping(name, uidstr, grouping);\n  }\n\n  private void initializeStorageIds(Configuration conf) throws IOException {\n    try {\n      Class<?> clazz = Class.forName(\"org.apache.hadoop.fs.BlockLocation\");\n      setStorageIds = clazz.getMethod(\"setStorageIds\", String[].class);\n    } catch (ClassNotFoundException e) {\n      throw new IllegalStateException(\n              \"Hadoop version was incompatible, current hadoop version is:\\t\" + VersionInfo.getVersion());\n    } catch (NoSuchMethodException e) {\n      setStorageIds = null;\n    }\n    int vdiskPerCpu = Integer.parseInt(getConf(conf, \"vdisk-per-cpu\", \"4\"));\n    storageIds = new String[java.lang.Runtime.getRuntime().availableProcessors() * vdiskPerCpu];\n    for (int i = 0; i < storageIds.length; i++) {\n      storageIds[i] = \"vd\" + i;\n    }\n  }\n\n  @Override\n  public Path getHomeDirectory() {\n    return makeQualified(new Path(homeDirPrefix + \"/\" + user));\n  }\n\n  private static void initStubLoader() {\n    int loadMaxTime = 30;","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java#L720-L756","documentation":"initializeStorageIds() reflectively loads org.apache.hadoop.fs.BlockLocation and its setStorageIds(String[]) method. If the class itself is missing from the classpath (a Hadoop that old cannot be supported at all), an IllegalStateException is thrown naming the current Hadoop version. A missing method is tolerated (setStorageIds = null).","triggerScenarios":"Class.forName(\"org.apache.hadoop.fs.BlockLocation\") throws ClassNotFoundException during initializeStorageIds() — effectively never in any real Hadoop, indicating BlockLocation is shaded/absent from the runtime classpath.","commonSituations":"Shaded/uber jars that exclude or relocate org.apache.hadoop classes; running the client outside Hadoop with only a partial classpath; classloader isolation (e.g. separate user classpath) hiding hadoop-common.","solutions":["Ensure hadoop-common is on the runtime classpath ('hadoop classpath' includes it).","Check for shading/relocation of org.apache.hadoop.fs classes in deployed jars.","Run inside a Hadoop environment (hadoop jar / YARN) rather than a bare JVM.","If it persists, log VersionInfo.getVersion() output and align the client jar with the cluster version."],"exampleFix":"// before\njava -cp juicefs-hadoop.jar App  # no hadoop-common -> IllegalStateException\n// after\nhadoop jar app.jar App  # or: -cp \"$(hadoop classpath):juicefs-hadoop.jar\"","handlingStrategy":"validation","validationCode":"try {\n  Class.forName(\"org.apache.hadoop.fs.BlockLocation\");\n} catch (ClassNotFoundException e) {\n  throw new IllegalStateException(\"hadoop-common missing from classpath: \"\n      + System.getProperty(\"java.class.path\"));\n}","typeGuard":null,"tryCatchPattern":"try { fs = FileSystem.get(uri, conf); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"Hadoop version was incompatible\")) { /* fix classpath / run under hadoop jar */ } throw e; }","preventionTips":["Always launch via 'hadoop jar' or include 'hadoop classpath' on the JVM classpath.","Avoid uber-jars that shade org.apache.hadoop classes.","Verify with a smoke test job before production rollout."],"tags":["hadoop","classpath","reflection"],"backgroundTag":"class-not-found","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}