{"record":{"id":"3ebfcfa763584d3c","repo":"quarkusio/quarkus","slug":"attempted-to-load-vetoed-class","errorCode":null,"errorMessage":"Attempted to load vetoed class '","messagePattern":"Attempted to load vetoed class '","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassLoaderLimiter.java","lineNumber":71,"sourceCode":"        }\n        if (resourceName.endsWith(\".class\")) {\n            //Skip further tracking on classes as it would create unnecessary noise\n            return;\n        }\n        final String previousLoad = allResourcesLoaded.put(resourceName, classLoaderName);\n        if (previousLoad != null) {\n            //This diagnostic has no flag, as it's generally useful, doesn't throw exceptions, and should\n            //generally not log much at all.\n            System.out.println(\n                    \"Resource loaded multiple times: \" + resourceName + \". Currently being loaded by \" + classLoaderName +\n                            \", previous loaded by \" + previousLoad);\n        }\n    }\n\n    @Override\n    public void loadClass(String className, String classLoaderName) {\n        if (vetoedClasses.contains(className)) {\n            throw new IllegalStateException(\n                    \"Attempted to load vetoed class '\" + className + \"' from classloader \" + classLoaderName);\n        } else if (vetoedRuntimeClasses.contains(className) && classLoaderName.toLowerCase(Locale.ROOT).contains(\"runtime\")) {\n            throw new IllegalStateException(\n                    \"Attempted to load vetoed class '\" + className + \"' from classloader \" + classLoaderName);\n        }\n    }\n\n    public static Builder builder() {\n        return new Builder();\n    }\n\n    public static class Builder {\n        private final Set<String> vetoedResources = new TreeSet<>();\n        private final Set<String> vetoedClasses = new TreeSet<>();\n        private final Set<String> vetoedRuntimeClasses = new TreeSet<>();\n        private final Set<String> atMostOnceResources = new TreeSet<>();\n        private final Set<String> onHitPrintStacktrace = new TreeSet<>();\n        private boolean traceAllResourceLoad = false;","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassLoaderLimiter.java#L53-L89","documentation":"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.","triggerScenarios":"A QuarkusClassLoader attempts to load a class whose name was registered via the limiter's vetoed-class configuration and loadClass is invoked for it.","commonSituations":"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.","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."],"exampleFix":"// before\nimport io.quarkus.deployment.util.ServiceUtil; // deployment class in runtime code -> vetoed\n// after\n// move the logic to deployment module or avoid the runtime-module import","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { loadAndUse(className); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"Attempted to load vetoed class\")) { reportLeak(className, e); } else { throw e; } }","preventionTips":["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."],"tags":["classloading","test-tooling","classloader-limiter"],"backgroundTag":"vetoed-class-load","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"}