quarkusio/quarkus · error · ClassLoaderLimiterConsistencyException

is being listed both as never loaded and as at most once

Error message

 is being listed both as never loaded and as at most once

What it means

Thrown by ClassLoaderLimiter.Builder.neverLoadedResource when the same resource name is registered twice as never-loaded, or when it was already registered as loaded-at-most-once. The limiter validates its internal bookkeeping sets are consistent so runtime veto checks are unambiguous. It is a developer/API misuse error, not a runtime classloading failure.

Source

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

         * If there is an attempt of loading the matched resource, a runtime exception will be thrown instead:
         * useful for running integration tests to verify your assumptions.
         * <p>
         * Limitations: if the resource is being loaded using the bootstrap classloader we
         * can't check it; some frameworks explicitly request using the base classloader
         * for resource loading (or even use the Filesystem API), so they can't be tested via this method.
         *
         * @param resourceFullName the resource name
         * @return this, for method chaining.
         */
        public Builder neverLoadedResource(String resourceFullName) {
            Objects.requireNonNull(resourceFullName);
            final boolean add = vetoedResources.add(resourceFullName);
            if (!add) {
                throw new ClassLoaderLimiterConsistencyException(
                        "resource listed multiple times as never loaded: " + resourceFullName);
            }
            if (atMostOnceResources.contains(resourceFullName)) {
                throw new ClassLoaderLimiterConsistencyException(
                        resourceFullName + " is being listed both as never loaded and as at most once");
            }
            return this;
        }

        /**
         * List a fully qualified class name as one that you don't expect to be loaded ever.
         * If there is an attempt of loading the matched class, a runtime exception will be thrown instead:
         * useful for running integration tests to verify your assumptions.
         * <p>
         * DO NOT list the name by doing using <code>literal.class.getName()</code> as this will implicitly get you
         * to load the class during the test, and produce a failure.
         * <p>
         * Limitations: if the class is being loaded using the bootstrap classloader we
         * can't check it. Most Quarkus extensions and frameworks will not use the bootstrap classloader,
         * but some code could make use of it explicitly.
         *
         * @param vetoedClassName the fully qualified class name

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove the duplicate neverLoadedResource call for that resource name
  2. Choose one classification: either neverLoadedResource or loadedAtMostOnceResource, not both
  3. Use a Set in the calling code to deduplicate resource names before feeding the builder

Example fix

// before
builder.neverLoadedResource("META-INF/foo.xml");
builder.loadedAtMostOnceResource("META-INF/foo.xml"); // throws
// after
builder.neverLoadedResource("META-INF/foo.xml");
Defensive patterns

Strategy: validation

Validate before calling

if (!neverLoaded.add(name)) throw new IllegalStateException("duplicate never-loaded resource: " + name);
if (atMostOnce.contains(name)) throw new IllegalStateException(name + " already marked at-most-once");

Prevention

When it happens

Trigger: Calling builder.neverLoadedResource(name) twice for the same resourceFullName, or calling it after loadedAtMostOnceResource(name) for the same name.

Common situations: Programmatic Quarkus bootstrap code (or generated Runner code) that lists vetoed resources in multiple places, e.g. a framework integration and app code both registering the same resource; copy-pasted builder chains.

Related errors


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