elastic/elasticsearch · error · InvalidUserDataException
Failed to build classpath URLs.
Error message
Failed to build classpath URLs.
What it means
Thrown while building a URL[] from a FileCollection for the fixtures classloader: one of the files produced a MalformedURLException from File.toURI().toURL(). toURI().toURL() almost never fails for real files, so this is a defensive guard for the rare case where the file path cannot be expressed as a valid URL.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/packer/CacheCacheableTestFixtures.java:127
}
}
private URLClassLoader createClassLoader(FileCollection classpath) {
if (classpath == null) {
throw new InvalidUserDataException("Missing 'classesDirs' or 'classpath' property.");
}
final Set<File> cpElements = new LinkedHashSet<>();
cpElements.addAll(classpath.getFiles());
final URL[] urls = new URL[cpElements.size()];
try {
int i = 0;
for (final File cpElement : cpElements) {
urls[i++] = cpElement.toURI().toURL();
}
assert i == urls.length;
} catch (MalformedURLException mfue) {
throw new InvalidUserDataException("Failed to build classpath URLs.", mfue);
}
return URLClassLoader.newInstance(urls, ClassLoader.getSystemClassLoader());
}
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Inspect the resolved classpath files (print files of the FileCollection) and look for null/non-file entries.
- Ensure the classpath is derived from real resolved configurations (configurations.runtimeClasspath) rather than ad-hoc providers.
- If a path is genuinely problematic, normalise/copy the artifact to a path with standard characters before building the URL.
- Check the wrapped MalformedURLException in the stack trace to see exactly which path failed.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate that every classpath file produces a usable URL
for (File f : classpath.getFiles()) {
try { f.toURI().toURL(); }
catch (MalformedURLException e) { throw new InvalidUserDataException("Bad classpath entry: " + f, e); }
} Try / catch
try {
URL[] urls = buildUrls(classpath);
} catch (InvalidUserDataException e) {
// surface the failing path from the wrapped MalformedURLException
throw new GradleException("Classpath URL build failed; check resolved artifacts exist", e);
} Prevention
- Derive classpaths from real resolved Gradle configurations, not string-built providers.
- Run a clean build when classpath entries go missing.
- Log the resolved file list at --info when debugging.
When it happens
Trigger: A classpath element whose File.toURI() returns a non-file/invalid URI that toURL() then rejects; typically a synthetic/placeholder file collection entry rather than a real artifact on disk.
Common situations: A custom FileCollection built from string-backed providers instead of real files; an artifact-resolved file that was deleted between configuration and execution; exotic paths with characters that break URI handling on some JVMs.
Related errors
- Cannot load VersionPropertiesBuildService
- Cannot resolve minimum compiler version via VersionPropertie
- Missing 'classesDirs' or 'classpath' property.
- Failed to build classpath URLs.
- Elasticsearch version is missing from properties.
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/312b5a6ee4d54a53.
Report an issue: GitHub.