{"record":{"id":"148ea6838e037730","repo":"apache/beam","slug":"unable-to-load-resourceid-path-with-classloader-url","errorCode":null,"errorMessage":"Unable to load \" + resourceId.path + \" with \" + classLoader + \" URL \" + classLoader.getResource(resourceId.path.substring(PREFIX.length()))","messagePattern":"Unable to load \" \\+ resourceId\\.path \\+ \" with \" \\+ classLoader \\+ \" URL \" \\+ classLoader\\.getResource\\(resourceId\\.path\\.substring\\(PREFIX\\.length\\(\\)\\)\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/io/ClassLoaderFileSystem.java","lineNumber":68,"sourceCode":"  @Override\n  protected List<MatchResult> match(List<String> specs) throws IOException {\n    throw new UnsupportedOperationException(\"Un-globbable filesystem.\");\n  }\n\n  @Override\n  protected WritableByteChannel create(\n      ClassLoaderResourceId resourceId, CreateOptions createOptions) throws IOException {\n    throw new UnsupportedOperationException(\"Read-only filesystem.\");\n  }\n\n  @Override\n  protected ReadableByteChannel open(ClassLoaderResourceId resourceId) throws IOException {\n    ClassLoader classLoader = getClass().getClassLoader();\n    InputStream inputStream =\n        classLoader.getResourceAsStream(resourceId.path.substring(PREFIX.length()));\n    if (inputStream == null) {\n\n      throw new IOException(\n          \"Unable to load \"\n              + resourceId.path\n              + \" with \"\n              + classLoader\n              + \" URL \"\n              + classLoader.getResource(resourceId.path.substring(PREFIX.length())));\n    }\n    return Channels.newChannel(inputStream);\n  }\n\n  @Override\n  protected void copy(\n      List<ClassLoaderResourceId> srcResourceIds, List<ClassLoaderResourceId> destResourceIds)\n      throws IOException {\n    throw new UnsupportedOperationException(\"Read-only filesystem.\");\n  }\n\n  @Override","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/io/ClassLoaderFileSystem.java#L50-L86","documentation":"ClassLoaderFileSystem.open loads a classpath resource via classLoader.getResourceAsStream. When the resource is not found, it throws this IOException including the resource path, the classloader, and the URL resolution result, to diagnose which classloader failed to find the resource.","triggerScenarios":"Opening a classpath:// resource whose path (after stripping the schema prefix) does not exist on the runtime classpath; resource present in a different classloader than getClass().getClassLoader().","commonSituations":"Typos or case mismatches in resource paths; resources in a dependency jar not on the runtime classpath; resources excluded by build packaging filters; different classloader hierarchy in app servers or shaded uber-jars.","solutions":["Verify the resource exists on the runtime classpath (inspect the jar/target-classes) and that the path spelling and case match exactly","Pre-check classLoader.getResource(path) != null before opening","Ensure the resource is packaged: check build excludes/filters and that the containing jar is a runtime dependency","If the classloader hierarchy differs (containers, shading), load via Thread.currentThread().getContextClassLoader() instead"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"String res = resourceId.path.substring(\"classpath://\".length());\nif (getClass().getClassLoader().getResource(res) == null) {\n  throw new IOException(\"resource not on classpath: \" + res);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return FileSystems.open(resourceId);\n} catch (IOException e) {\n  LOG.error(\"classpath resource missing: \" + resourceId, e);\n  throw e;\n}","preventionTips":["Verify resource packaging (jar contents) in the build","Match path case and separators exactly as packaged","Test resource loading in the actual runtime environment with the same classloader setup"],"tags":[],"backgroundTag":null,"analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}