quarkusio/quarkus · error · RuntimeException
Failed to translate
Error message
Failed to translate
What it means
Thrown from PathTreeClassPathElement.getUrl when translating the element's internal path into a java.net.URL fails with MalformedURLException, wrapped in a RuntimeException. This method builds runtime URLs for classpath elements (handling escaping of special characters like '?'). Failure means the resource path cannot be represented as a valid URL.
Source
Thrown at independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/PathTreeClassPathElement.java:257
// (one with a trailing slash and one without) for same resource
if (uri.getPath() != null && uri.getPath().endsWith("/")) {
String uriStr = uri.toString();
url = new URL(uriStr.substring(0, uriStr.length() - 1));
} else {
url = uri.toURL();
}
if (url.getQuery() != null) {
//huge hack to work around a JDK bug. ZipPath does not escape properly, so if there is a ?
//in the path then it ends up in the query string and everything is screwy.
//if there are multiple question marks the extra ones end up in the path and not the query string as you would expect
url = new URL(url.getProtocol(), url.getHost(), url.getPort(),
url.getPath().replaceAll("\\?", "%3F") + "%3F" + url.getQuery());
}
return this.url = url;
}
return url = apply(this::getUrl);
} catch (MalformedURLException e) {
throw new RuntimeException("Failed to translate " + path + " to URL", e);
} finally {
lock.readLock().unlock();
}
}
/**
* URL for this resource in a given {@link OpenPathTree}.
* If the path tree contains the resource, its URL is returned.
* Otherwise, the method returns null.
*
* @param tree path tree to look for the resource in
* @return resource URL if it exists in a given path tree or null if it does not
*/
private URL getUrl(OpenPathTree tree) {
return tree.apply(name, Resource::getUrl);
}
/**View on GitHub (pinned to e1c734241f)
Solutions
- Rename the offending directory/jar to remove reserved URL characters ('?', '#', spaces)
- Inspect the cause MalformedURLException to identify the offending character
- Run the application from a conventional location (plain alphanumeric path)
Example fix
// before /path/to/my?app/runner.jar // '?' breaks URL translation // after /path/to/my_app/runner.jar
Defensive patterns
Strategy: validation
Validate before calling
String p = path.toString();
if (p.contains("?") || p.contains("#") || p.contains(" ")) {
throw new IllegalStateException("path contains URL-reserved characters: " + p);
} Prevention
- Avoid '?', '#', and spaces in application directory/jar names
- Test the app from a simple alphanumeric path if URL errors appear
- Check the MalformedURLException cause to find the offending character
When it happens
Trigger: Calling getUrl() on a PathTreeClassPathElement whose path contains characters that break URL parsing and are not correctly escaped (e.g. '?', spaces) so that MalformedURLException is thrown.
Common situations: Running from directories/jars whose names include '?' or other reserved URL characters; unusual build output locations.
Related errors
- Unable to create protection domain for
- Invalid URL:
- java.io.UncheckedIOException
- Unable to create protection domain for ${jarPath}
- Failed to create output directory for generated sources: %s
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/21c9e77cf60017b8.
Report an issue: GitHub.