{"record":{"id":"c141a08d8b03b504","repo":"quarkusio/quarkus","slug":"illegalstateexception-wrapping-classnotfoundexcept","errorCode":null,"errorMessage":"IllegalStateException wrapping ClassNotFoundException for generated static-method initializer class (no own message)","messagePattern":"IllegalStateException wrapping ClassNotFoundException for generated static-method initializer class \\(no own message\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/InterceptedStaticMethodsRecorder.java","lineNumber":19,"sourceCode":"package io.quarkus.arc.runtime;\n\nimport io.quarkus.runtime.annotations.Recorder;\n\n@Recorder\npublic class InterceptedStaticMethodsRecorder {\n\n    // This class is generated and calls all generated static interceptor initializers to register metadata in the InterceptedStaticMethods class\n    public static final String INITIALIZER_CLASS_NAME = \"io.quarkus.arc.runtime.InterceptedStaticMethodsInitializer\";\n\n    public void callInitializer() {\n        ClassLoader cl = Thread.currentThread().getContextClassLoader();\n        if (cl == null) {\n            cl = InterceptedStaticMethodsRecorder.class.getClassLoader();\n        }\n        try {\n            Class.forName(INITIALIZER_CLASS_NAME, true, cl);\n        } catch (ClassNotFoundException e) {\n            throw new IllegalStateException(e);\n        }\n    }\n\n}\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/InterceptedStaticMethodsRecorder.java#L1-L24","documentation":"This IllegalStateException is thrown by InterceptedStaticMethodsRecorder.callInitializer when Class.forName cannot find the generated static-method initializer class (INITIALIZER_CLASS_NAME). The initializer class is generated at build time by the ArC deployment step that supports intercepted static methods; if it is missing at runtime, the CDI intercepted-static-methods integration is broken. The ClassNotFoundException is wrapped to preserve the cause while surfacing a runtime failure.","triggerScenarios":"Calling InterceptedStaticMethodsRecorder.callInitializer(String, String, ClassLoader) at application startup when the build-time-generated initializer class is absent from the classloader hierarchy (e.g. wrong classloader passed, or the deployment code generation step did not run).","commonSituations":"Custom launchers or dev-mode tooling invoking callInitializer with a classloader that cannot see generated classes; upgrades where the intercepted static methods bytecode generation was skipped or its output excluded; packaging the app in a way that drops generated classes.","solutions":["Verify the ArC deployment build step for intercepted static methods ran and the generated initializer class exists in the application bytecode","Ensure the ClassLoader passed to callInitializer can load classes generated for the application (try the Thread.currentThread().getContextClassLoader() or the application classloader)","Rebuild the application cleanly so the deployment-time code generation re-runs","Check that packaging tooling (shade plugins, native-image config) is not excluding the generated initializer class"],"exampleFix":"// before\nInterceptedStaticMethodsRecorder.callInitializer(\"com.example.App\", \"start\", someRestrictedClassLoader);\n// after\nInterceptedStaticMethodsRecorder.callInitializer(\"com.example.App\", \"start\",\n        Thread.currentThread().getContextClassLoader());","handlingStrategy":"try-catch","validationCode":"try {\n    Class.forName(\"io.quarkus.arc.runtime.InterceptedStaticMethodsRecorder$$StaticInit\", true, cl);\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"Static-method initializer class missing; rebuild the app\", e);\n}","typeGuard":"boolean initializerPresent(ClassLoader cl) {\n    try { Class.forName(\"io.quarkus.arc.runtime.InterceptedStaticMethodsRecorder$$StaticInit\", false, cl); return true; }\n    catch (ClassNotFoundException e) { return false; }\n}","tryCatchPattern":"try {\n    recorder.callInitializer(cls, methodName, cl);\n} catch (IllegalStateException e) {\n    logger.error(\"Generated static initializer not found; check ArC build output\", e);\n}","preventionTips":["Always pass an application-capable ClassLoader (context classloader), not a restricted one","Keep quarkus-arc deployment processing intact; avoid excluding generated classes in packaging","Clean-rebuild after upgrading Quarkus so generated initializer classes are regenerated"],"tags":["quarkus","arc","cdi","classpath","generated-code"],"backgroundTag":"class-not-found","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}