quarkusio/quarkus · error · IllegalStateException

Attempted to load vetoed resource '

Error message

Attempted to load vetoed resource '

What it means

ClassLoaderLimiter is a test/diagnostic hook that can veto specific resources. openResourceStream throws this IllegalStateException when the resource name appears in the configured vetoedResources set, deliberately failing the load so tests can assert a resource is never requested from the given classloader.

Source

Thrown at independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassLoaderLimiter.java:44

        vetoedRuntimeClasses = builder.vetoedRuntimeClasses;
        atMostOnceResources = builder.atMostOnceResources;
        onHitPrintStacktrace = builder.onHitPrintStacktrace;
        traceAllResourceLoad = builder.traceAllResourceLoad;
    }

    @Override
    public void openResourceStream(String resourceName, String classLoaderName) {
        Objects.requireNonNull(resourceName);
        Objects.requireNonNull(classLoaderName);
        if (traceAllResourceLoad) {
            System.out.println("Opening resource: " + resourceName);
        }
        if (onHitPrintStacktrace.contains(resourceName)) {
            final RuntimeException e = new RuntimeException("Tracing load of resource: " + resourceName);
            e.printStackTrace();
        }
        if (vetoedResources.contains(resourceName)) {
            throw new IllegalStateException(
                    "Attempted to load vetoed resource '" + resourceName + "' from classloader " + classLoaderName);
        }
        if (atMostOnceResources.contains(resourceName)) {
            final String previousLoadEvent = atMostOnceResourcesLoaded.put(resourceName, classLoaderName);
            if (previousLoadEvent != null) {
                throw new IllegalStateException("Resource being loaded more than once: " + resourceName + ".\n" +
                        "Attempted load by " + classLoaderName + ", recorded previous load by " + previousLoadEvent);
            }
        }
        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(

View on GitHub (pinned to e1c734241f)

Solutions

  1. Fix application/library code to stop requesting the vetoed resource in that classloader.
  2. If the load is now legitimate, remove the resource from the limiter's neverLoadedResource builder configuration.
  3. Use the stack trace accompanying the failure to find which code path performs the unwanted load.

Example fix

// before
ClassLoaderLimiter.builder().neverLoadedResource("quarkus-dev-mode.properties")...
// after (if the load is legitimate now)
ClassLoaderLimiter.builder()... // remove neverLoadedResource("quarkus-dev-mode.properties")
Defensive patterns

Strategy: validation

Validate before calling

// before opening the resource, check limiter config
if (limiterVetoedResources.contains(resourceName)) {
    throw new AssertionError("Code path must not read " + resourceName);
}

Try / catch

try { cl.getResourceAsStream(name); } catch (IllegalStateException e) { if (e.getMessage().startsWith("Attempted to load vetoed resource")) { failWithStacktrace(e); } else { throw e; } }

Prevention

When it happens

Trigger: A QuarkusClassLoader created with a ClassLoaderLimiter that lists a resource in vetoedResources attempts to open that resource; openResourceStream is called for it.

Common situations: Quarkus core/integration tests enforcing that, e.g., dev-mode or runtime resources are never touched in certain modes; regressions where new code starts reading a resource that must not be loaded.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/a5c7cc6ef6bfbb60. Report an issue: GitHub.