{"record":{"id":"c2872a21f1995b0b","repo":"quarkusio/quarkus","slug":"unable-to-create-invoker","errorCode":null,"errorMessage":"Unable to create invoker: ","messagePattern":"Unable to create invoker: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/scheduler/common/src/main/java/io/quarkus/scheduler/common/runtime/SchedulerContext.java","lineNumber":33,"sourceCode":"\n    boolean forceSchedulerStart();\n\n    List<ScheduledMethod> getScheduledMethods(String implementation);\n\n    boolean matchesImplementation(Scheduled scheduled, String implementation);\n\n    String autoImplementation();\n\n    @SuppressWarnings(\"unchecked\")\n    default ScheduledInvoker createInvoker(String invokerClassName) {\n        try {\n            Class<? extends ScheduledInvoker> invokerClazz = (Class<? extends ScheduledInvoker>) Thread.currentThread()\n                    .getContextClassLoader()\n                    .loadClass(invokerClassName);\n            return invokerClazz.getDeclaredConstructor().newInstance();\n        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException\n                | InvocationTargetException e) {\n            throw new IllegalStateException(\"Unable to create invoker: \" + invokerClassName, e);\n        }\n    }\n}\n","sourceCodeStart":15,"sourceCodeEnd":37,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/scheduler/common/src/main/java/io/quarkus/scheduler/common/runtime/SchedulerContext.java#L15-L37","documentation":"SchedulerContext.createInvoker() loads the generated ScheduledInvoker class (recorded at build time) by name from the thread context classloader and instantiates it reflectively. If loading or construction fails (class missing, wrong classloader, constructor issue), it wraps the cause in this IllegalStateException including the invoker class name.","triggerScenarios":"The invoker class recorded by the scheduler deployment module cannot be loaded: wrong Thread.currentThread().getContextClassLoader() at scheduler startup; QuarkusClassLoader already closed (app shutdown/restart); generated class absent from the artifact; reflective instantiation failure (no default constructor, security manager restriction).","commonSituations":"Running the scheduler outside the Quarkus runtime classloader (custom main/tests); dev-mode hot reload while a scheduled job fires; shaded/fat-jar packaging dropping generated classes; scheduler initialized from a background thread with no app classloader context.","solutions":["Ensure scheduler startup runs on a thread whose context classloader is the Quarkus runtime classloader (use Arc.container() or the app classloader explicitly)","Rebuild the application so generated invoker classes are present; don't strip build-time generated sources","In tests, bootstrap with @QuarkusTest rather than manually constructing SchedulerContext","Inspect the wrapped cause (InstantiationException/ClassNotFoundException etc.) to pinpoint whether it's a classloading or construction problem"],"exampleFix":"// before (custom bootstrap, wrong classloader)\nThread.currentThread().setContextClassLoader(someLibLoader);\nSchedulerContext.createInvoker(\"...Invoker\");\n// after\nThread.currentThread().setContextClassLoader(appClassloader); // Quarkus runtime CL\nSchedulerContext.createInvoker(\"com.example.MyJob_Invoker\");","handlingStrategy":"try-catch","validationCode":"ClassLoader cl = Thread.currentThread().getContextClassLoader();\ntry {\n    Class.forName(invokerClassName, false, cl);\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"Invoker class not visible from TCCL: \" + invokerClassName, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    invoker = schedulerContext.createInvoker(className);\n} catch (IllegalStateException e) {\n    LOG.error(\"Failed to create scheduled invoker {} - check classloader/rebuild\", className, e.getCause());\n}","preventionTips":["Let Quarkus bootstrap the scheduler; avoid custom main/test harnesses with foreign classloaders","Rebuild the app after changing scheduler-related code so invoker classes regenerate","Avoid stripping generated classes from packaged artifacts","Inspect getCause() (ClassNotFoundException vs InstantiationException) when debugging"],"tags":["scheduler","classloading","reflection","startup"],"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"}