{"record":{"id":"a7b6b43a47ac399d","repo":"quarkusio/quarkus","slug":"resource-listed-multiple-times-as-loaded-at-most-o","errorCode":null,"errorMessage":"resource listed multiple times as loaded at most once: ","messagePattern":"resource listed multiple times as loaded at most once: ","errorType":"exception","errorClass":"ClassLoaderLimiterConsistencyException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassLoaderLimiter.java","lineNumber":188,"sourceCode":"         * Useful to check that a resource is being loaded only once, or never.\n         * If there is an attempt of loading the matched resource more than once, a runtime exception will be thrown instead:\n         * useful for running integration tests to verify your assumptions.\n         * <p>\n         * Limitations: if the resource is being loaded using the bootstrap classloader we\n         * can't check it; some frameworks explicitly request using the base classloader\n         * for resource loading (or even use the Filesystem API), so they can't be tested via this method.\n         * Additionally, some frameworks will load the same resource but in different Quarkus build\n         * phases (which map to different classloaders); such cases will count as multiple times\n         * so it might not be suited to test this way.\n         *\n         * @param resourceFullName the resource name\n         * @return this, for method chaining.\n         */\n        public Builder loadedAtMostOnceResource(String resourceFullName) {\n            Objects.requireNonNull(resourceFullName);\n            final boolean add = atMostOnceResources.add(resourceFullName);\n            if (!add)\n                throw new ClassLoaderLimiterConsistencyException(\n                        \"resource listed multiple times as loaded at most once: \" + resourceFullName);\n            if (vetoedResources.contains(resourceFullName)) {\n                throw new ClassLoaderLimiterConsistencyException(\n                        resourceFullName + \" is being listed both as never loaded and as at most once\");\n            }\n            return this;\n        }\n\n        /**\n         * When the specified resource is loaded, print a full stack trace on System out.\n         * This is not useful for testing, but handy to trace were a certain load is coming from,\n         * should you need to diagnose a failing expectation.\n         *\n         * @param resourceFullName\n         * @return this, for method chaining.\n         */\n        public Builder produceStackTraceOnLoad(String resourceFullName) {\n            Objects.requireNonNull(resourceFullName);","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassLoaderLimiter.java#L170-L206","documentation":"Thrown by ClassLoaderLimiter.Builder.loadedAtMostOnceResource when the same resource name is registered twice as loaded-at-most-once. The limiter tracks these resources to assert each is loaded zero or one times, so duplicates would corrupt that assertion. It is a misuse of the builder API at bootstrap time.","triggerScenarios":"Calling builder.loadedAtMostOnceResource(name) twice for the same resourceFullName (Set.add returns false).","commonSituations":"Two integrations or generated code paths both marking the same resource (e.g. a service file) as at-most-once.","solutions":["Deduplicate resource names before calling the builder","Remove one of the duplicate registrations","Keep ownership of at-most-once registration in a single component"],"exampleFix":"// before\nbuilder.loadedAtMostOnceResource(\"META-INF/services/com.foo.Service\");\nbuilder.loadedAtMostOnceResource(\"META-INF/services/com.foo.Service\"); // throws\n// after\nif (resourcesSeen.add(\"META-INF/services/com.foo.Service\")) builder.loadedAtMostOnceResource(\"META-INF/services/com.foo.Service\");","handlingStrategy":"validation","validationCode":"if (!atMostOnceSeen.add(name)) { /* skip */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a Set to deduplicate at-most-once resource names","Register each resource from exactly one component","Review generated builder code for repeated entries"],"tags":["classloading","bootstrap","builder-validation"],"backgroundTag":"duplicate-registration","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}