apache/hadoop · error · RuntimeException
EC policy file {url} found on the classpath is not on the lo
Error message
EC policy file {url} found on the classpath is not on the local filesystem. What it means
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().
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java:231
}
}
return policies;
}
/**
* Path to the XML file containing user defined EC policies. If the path is
* relative, it is searched for in the classpath.
* @param policyFilePath path of EC policy file
* @return EC policy file
*/
private File getPolicyFile(String policyFilePath)
throws MalformedURLException {
File policyFile = new File(policyFilePath);
if (!policyFile.isAbsolute()) {
URL url = new URL(policyFilePath);
if (!url.getProtocol().equalsIgnoreCase("file")) {
throw new RuntimeException(
"EC policy file " + url
+ " found on the classpath is not on the local filesystem.");
} else {
policyFile = new File(url.getPath());
}
}
return policyFile;
}
/**
* Load a schema from a schema element in the XML configuration file.
* @param element EC schema element
* @return ECSchema
*/
private ECSchema loadSchema(Element element) {
Map<String, String> schemaOptions = new HashMap<String, String>();
NodeList fields = element.getChildNodes();View on GitHub (pinned to 2add963021)
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
Example fix
# before hdfs ec -loadPolicy http://config-host/user_ec_policies.xml # after curl -o /tmp/user_ec_policies.xml http://config-host/user_ec_policies.xml hdfs ec -loadPolicy /tmp/user_ec_policies.xml
Defensive patterns
Strategy: validation
Validate before calling
File f = new File(policyFilePath);
if (!f.isAbsolute()) {
URL u = new URL(policyFilePath); // throws MalformedURLException if no protocol
if (!"file".equalsIgnoreCase(u.getProtocol())) {
throw new IllegalArgumentException(policyFilePath + " is not a local file path or file: URL");
}
f = new File(u.getPath());
} Try / catch
try { new ECPolicyLoader().loadPolicy(path); }
catch (RuntimeException e) {
LOG.error("Cannot load EC policies from {}: {}", path, e.getMessage()); // point user at local path requirement
} Prevention
- Always pass an absolute local path to `hdfs ec -loadPolicy`
- Download remote policy files with curl/hdfs dfs -get before loading
When it happens
Trigger: `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'.
Common situations: 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.
Related errors
- Policy '%s' does not match any enabled erasure coding polici
- The given erasure coding policy {} does not exist.
- Failed to load EC policy file: {policyFilePath}
- Bad EC policy configuration file: top-level element not <con
- Bad EC policy configuration file: no <policies> element
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/e0680e4fe2cc9af0.
Report an issue: GitHub.