{"record":{"id":"e0680e4fe2cc9af0","repo":"apache/hadoop","slug":"ec-policy-file-url-found-on-the-classpath-is-not","errorCode":null,"errorMessage":"EC policy file {url} found on the classpath is not on the local filesystem.","messagePattern":"EC policy file (.+?) found on the classpath is not on the local filesystem\\.","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java","lineNumber":231,"sourceCode":"      }\n    }\n\n    return policies;\n  }\n\n  /**\n   * Path to the XML file containing user defined EC policies. If the path is\n   * relative, it is searched for in the classpath.\n   * @param policyFilePath path of EC policy file\n   * @return EC policy file\n   */\n  private File getPolicyFile(String policyFilePath)\n      throws MalformedURLException {\n    File policyFile = new File(policyFilePath);\n    if (!policyFile.isAbsolute()) {\n      URL url = new URL(policyFilePath);\n      if (!url.getProtocol().equalsIgnoreCase(\"file\")) {\n        throw new RuntimeException(\n            \"EC policy file \" + url\n                + \" found on the classpath is not on the local filesystem.\");\n      } else {\n        policyFile = new File(url.getPath());\n      }\n    }\n\n    return policyFile;\n  }\n\n  /**\n   * Load a schema from a schema element in the XML configuration file.\n   * @param element EC schema element\n   * @return ECSchema\n   */\n  private ECSchema loadSchema(Element element) {\n    Map<String, String> schemaOptions = new HashMap<String, String>();\n    NodeList fields = element.getChildNodes();","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java#L213-L249","documentation":"ECPolicyLoader.getPolicyFile() treats a non-absolute policy file path as a URL and requires the file: protocol. If the URL parses but uses another scheme (http://, https://, jar:, ftp:// ...), it throws this RuntimeException because the loader can only read local files. A plain relative filename without a scheme never reaches this message — it fails URL parsing and surfaces as the wrapped 'Failed to load EC policy file' RuntimeException from loadPolicy().","triggerScenarios":"`hdfs ec -loadPolicy http://host/user_ec_policies.xml` (or any non-file URL) — the path is relative, parses as a URL, and its protocol is not 'file'.","commonSituations":"Trying to load the policy file straight from a web server, HDFS web UI, or documentation link instead of downloading it first; passing a jar: classpath URL.","solutions":["Download the file to local disk and pass a local absolute path: hdfs ec -loadPolicy /etc/hadoop/conf/user_ec_policies.xml","Or use a file: URL: file:///etc/hadoop/conf/user_ec_policies.xml","If you intended a classpath-style relative reference, place the file on the local filesystem and give an absolute path instead"],"exampleFix":"# before\nhdfs ec -loadPolicy http://config-host/user_ec_policies.xml\n\n# after\ncurl -o /tmp/user_ec_policies.xml http://config-host/user_ec_policies.xml\nhdfs ec -loadPolicy /tmp/user_ec_policies.xml","handlingStrategy":"validation","validationCode":"File f = new File(policyFilePath);\nif (!f.isAbsolute()) {\n  URL u = new URL(policyFilePath); // throws MalformedURLException if no protocol\n  if (!\"file\".equalsIgnoreCase(u.getProtocol())) {\n    throw new IllegalArgumentException(policyFilePath + \" is not a local file path or file: URL\");\n  }\n  f = new File(u.getPath());\n}","typeGuard":null,"tryCatchPattern":"try { new ECPolicyLoader().loadPolicy(path); }\ncatch (RuntimeException e) {\n  LOG.error(\"Cannot load EC policies from {}: {}\", path, e.getMessage()); // point user at local path requirement\n}","preventionTips":["Always pass an absolute local path to `hdfs ec -loadPolicy`","Download remote policy files with curl/hdfs dfs -get before loading"],"tags":["hdfs","erasure-coding","ec-policy","url","local-filesystem"],"backgroundTag":"unsupported-url-scheme","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}