quarkusio/quarkus · error · IllegalStateException
Attempted to load vetoed class '
Error message
Attempted to load vetoed class '
What it means
ClassLoaderLimiter.loadClass vetoes class loads: if the class name is in vetoedClasses, this IllegalStateException is thrown, failing the load request. It lets tests assert that a given class is never loaded by the monitored classloader.
Source
Thrown at independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassLoaderLimiter.java:71
}
if (resourceName.endsWith(".class")) {
//Skip further tracking on classes as it would create unnecessary noise
return;
}
final String previousLoad = allResourcesLoaded.put(resourceName, classLoaderName);
if (previousLoad != null) {
//This diagnostic has no flag, as it's generally useful, doesn't throw exceptions, and should
//generally not log much at all.
System.out.println(
"Resource loaded multiple times: " + resourceName + ". Currently being loaded by " + classLoaderName +
", previous loaded by " + previousLoad);
}
}
@Override
public void loadClass(String className, String classLoaderName) {
if (vetoedClasses.contains(className)) {
throw new IllegalStateException(
"Attempted to load vetoed class '" + className + "' from classloader " + classLoaderName);
} else if (vetoedRuntimeClasses.contains(className) && classLoaderName.toLowerCase(Locale.ROOT).contains("runtime")) {
throw new IllegalStateException(
"Attempted to load vetoed class '" + className + "' from classloader " + classLoaderName);
}
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private final Set<String> vetoedResources = new TreeSet<>();
private final Set<String> vetoedClasses = new TreeSet<>();
private final Set<String> vetoedRuntimeClasses = new TreeSet<>();
private final Set<String> atMostOnceResources = new TreeSet<>();
private final Set<String> onHitPrintStacktrace = new TreeSet<>();
private boolean traceAllResourceLoad = false;View on GitHub (pinned to e1c734241f)
Solutions
- Remove the code reference that causes the vetoed class to load (use the stack trace to find it).
- If the class must be loaded, remove the class from the limiter's veto list configuration.
- Introduce indirection/reflection or move the dependent code to a classloader where the class is allowed.
Example fix
// before import io.quarkus.deployment.util.ServiceUtil; // deployment class in runtime code -> vetoed // after // move the logic to deployment module or avoid the runtime-module import
Defensive patterns
Strategy: try-catch
Try / catch
try { loadAndUse(className); } catch (IllegalStateException e) { if (e.getMessage().startsWith("Attempted to load vetoed class")) { reportLeak(className, e); } else { throw e; } } Prevention
- Never reference deployment/limited classes from runtime code paths.
- Keep veto lists minimal and documented in the test setup.
- Use the exception stack trace to locate the offending reference immediately.
When it happens
Trigger: A QuarkusClassLoader attempts to load a class whose name was registered via the limiter's vetoed-class configuration and loadClass is invoked for it.
Common situations: Quarkus tests asserting that e.g. deployment or dev-mode-only classes never leak into runtime classloaders; a regression introduces a reference that triggers loading of the forbidden class.
Related errors
- Attempted to load vetoed resource '
- Resource being loaded more than once:
- resource listed multiple times as never loaded:
- Failed to load steps from %s
- The class (${name}) cannot be created during deployment.
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/3ebfcfa763584d3c.
Report an issue: GitHub.