quarkusio/quarkus · error · IllegalArgumentException
Invalid URL:
Error message
Invalid URL:
What it means
Thrown from MemoryClassPathElement.getUrl when constructing the quarkus: memory URL for an in-memory resource fails with MalformedURLException, and rethrown as IllegalArgumentException. The quarkus: protocol relies on MemoryUrlStreamHandler being registered; URL construction should normally succeed. Receiving this means the URL factory infrastructure was unavailable or the path was malformed.
Source
Thrown at independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/MemoryClassPathElement.java:95
@Override
public ClassPathElement getContainingElement() {
return MemoryClassPathElement.this;
}
@Override
public String getPath() {
return name;
}
@Override
public URL getUrl() {
String path = "quarkus:" + name;
try {
URL url = new URL(null, path, new MemoryUrlStreamHandler(resources.get(name), lastModified));
return url;
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Invalid URL: " + path);
}
}
@Override
public byte[] getData() {
return res;
}
@Override
public boolean isDirectory() {
return false;
}
};
}
@Override
public Set<String> getProvidedResources() {
return resources.keySet();View on GitHub (pinned to e1c734241f)
Solutions
- Ensure MemoryURLStreamHandlerFactory is installed (URL.setURLStreamHandlerFactory) before creating memory class path elements
- Check the resource name for invalid URL characters
- Run within standard Quarkus bootstrap which installs the factory automatically
Example fix
// before URL.setURLStreamHandlerFactory(new TomcatURLStreamHandlerFactory()); // displaces quarkus handler // after URL.setURLStreamHandlerFactory(new MemoryURLStreamHandlerFactory()); // or composite factory including it
Defensive patterns
Strategy: try-catch
Validate before calling
try {
new URL(null, "quarkus:" + name, new MemoryUrlStreamHandler(bytes, lastModified));
} catch (MalformedURLException e) { /* handler factory missing or bad name */ } Type guard
boolean isMemoryUrlSupported(String name) {
return URL.getURLStreamHandler("quarkus") != null
&& name.chars().allMatch(c -> c > 32 && c < 127);
} Try / catch
try {
URL url = element.getUrl();
} catch (IllegalArgumentException e) {
throw new IllegalStateException("Memory URL support unavailable; install MemoryURLStreamHandlerFactory", e);
} Prevention
- Install MemoryURLStreamHandlerFactory before any memory classpath element is used
- Avoid custom URL.setURLStreamHandlerFactory calls that displace the quarkus handler
- Keep resource names URL-safe
When it happens
Trigger: Calling getUrl() on a MemoryClassPathElement when new URL(null, "quarkus:"+name, handler) throws MalformedURLException — typically because the MemoryURLStreamHandlerFactory was never installed on the URL stream handler factory.
Common situations: Tests or embedded usage that create MemoryClassPathElement instances without registering the memory URL stream handler factory; name containing characters that break URL parsing.
Related errors
- is being listed both as never loaded and as at most once
- never loaded class listed multiple times:
- resource listed multiple times as loaded at most once:
- Unable to create protection domain for
- Failed to translate
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/fc206390c58ad96c.
Report an issue: GitHub.