{"record":{"id":"bd1a713aecd48e8e","repo":"apache/hadoop","slug":"could-not-initialize-target-file-system-for-uri","errorCode":null,"errorMessage":"Could not initialize target File System for URI : {targetDirLinkList[0]}","messagePattern":"Could not initialize target File System for URI : (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java","lineNumber":408,"sourceCode":"     * Get the instance of FileSystem to use, creating one if needed.\n     * @return An Initialized instance of T\n     * @throws IOException raised on errors performing I/O.\n     */\n    public T getTargetFileSystem() throws IOException {\n      if (targetFileSystem != null) {\n        return targetFileSystem;\n      }\n      // For non NFLY and MERGE links, we initialize the FileSystem when the\n      // corresponding mount path is accessed.\n      if (targetDirLinkList.length == 1) {\n        synchronized (lock) {\n          if (targetFileSystem != null) {\n            return targetFileSystem;\n          }\n          targetFileSystem =\n              fileSystemInitMethod.apply(URI.create(targetDirLinkList[0]));\n          if (targetFileSystem == null) {\n            throw new IOException(\n                \"Could not initialize target File System for URI : \" +\n                    targetDirLinkList[0]);\n          }\n        }\n      }\n      return targetFileSystem;\n    }\n\n    T getTargetFileSystemForClose() throws IOException {\n      return targetFileSystem;\n    }\n\n  }\n\n  private void createLink(final String src, final String target,\n      final LinkType linkType, final String settings,\n      final UserGroupInformation aUgi,\n      final Configuration config)","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java#L390-L426","documentation":"In InodeTree, each single mount link holds a target FileSystem that is created lazily: the first access to the mounted path calls fileSystemInitMethod.apply(URI.create(target)). If that returns null, IOException('Could not initialize target File System for URI : <uri>') is thrown. The failure surfaces at first path access, not when the ViewFileSystem is created.","triggerScenarios":"A mount table link whose target URI uses a scheme with no FileSystem implementation or a broken factory; accessing any path under such a mount; custom fileSystemInitMethod implementations that return null.","commonSituations":"Typo'd scheme in a link target ('hdfs2://', 'hdf://'); missing connector jar for the target store; federated configs referencing decommissioned clusters.","solutions":["Verify the target standalone first: FileSystem.get(URI.create(linkTarget), conf) must succeed","Fix the scheme/URI in the fs.viewfs.mounttable.<name>.link.<path> entry","Ensure the FileSystem implementation jar is on the client classpath"],"exampleFix":"<!-- before -->\n<property><name>fs.viewfs.mounttable.cluster.link./data</name>\n  <value>hdfs2://nnA/data</value></property>\n\n<!-- after -->\n<property><name>fs.viewfs.mounttable.cluster.link./data</name>\n  <value>hdfs://nnA/data</value></property>","handlingStrategy":"try-catch","validationCode":"static boolean targetResolvable(String linkTarget, Configuration conf) {\n  try {\n    return FileSystem.get(URI.create(linkTarget), conf) != null;\n  } catch (IOException e) {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"Wrap the first access to each mount point in try/catch IOException; on 'Could not initialize target File System for URI', extract the URI from the message and verify it standalone with FileSystem.get(uri, conf).","preventionTips":["Smoke-test every link target URI before shipping viewfs config","Keep connector jars on the client classpath","Fail at config-check time rather than at first path access"],"tags":["hadoop","viewfs","mount-table","filesystem","lazy-init","uri"],"backgroundTag":"unsupported-filesystem-scheme","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}