{"record":{"id":"96fc22d5625588c7","repo":"quarkusio/quarkus","slug":"unable-to-handle-class-applicationclass-96fc22","errorCode":null,"errorMessage":"Unable to handle class: ${applicationClass}","messagePattern":"Unable to handle class: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java","lineNumber":120,"sourceCode":"                application = (Application) appClass.getConstructor().newInstance();\n                Set<Class<?>> classes = application.getClasses();\n                if (!classes.isEmpty()) {\n                    for (Class<?> klass : classes) {\n                        allowedClasses.add(klass.getName());\n                    }\n                    filterClasses = true;\n                }\n                classes = application.getSingletons().stream().map(Object::getClass).collect(Collectors.toSet());\n                if (!classes.isEmpty()) {\n                    for (Class<?> klass : classes) {\n                        allowedClasses.add(klass.getName());\n                        singletonClasses.add(klass.getName());\n                    }\n                    filterClasses = true;\n                }\n            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException\n                    | InvocationTargetException e) {\n                throw new RuntimeException(\"Unable to handle class: \" + applicationClass, e);\n            }\n            // collect default behaviour, making sure that we don't have multiple contradicting annotations\n            int numAnnotations = 0;\n            if (applicationClassInfo.hasDeclaredAnnotation(ResteasyReactiveDotNames.BLOCKING)) {\n                blocking = BlockingDefault.BLOCKING;\n                numAnnotations++;\n            }\n            if (applicationClassInfo.hasDeclaredAnnotation(ResteasyReactiveDotNames.NON_BLOCKING)) {\n                blocking = BlockingDefault.NON_BLOCKING;\n                numAnnotations++;\n            }\n            if (applicationClassInfo.hasDeclaredAnnotation(ResteasyReactiveDotNames.RUN_ON_VIRTUAL_THREAD)) {\n                blocking = BlockingDefault.RUN_ON_VIRTUAL_THREAD;\n                numAnnotations++;\n            }\n            if (numAnnotations > 1) {\n                throw new DeploymentException(\"JAX-RS Application class '\" + applicationClassInfo.name()\n                        + \"' contains multiple conflicting @Blocking, @NonBlocking and @RunOnVirtualThread annotations.\");","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java#L102-L138","documentation":"After selecting the Application class, the scanner instantiates it via TCCL loadClass + newInstance to read its getClasses()/getSingletons() output. If loading, constructing, or reflectively invoking the class fails (ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException), the underlying cause is wrapped in this RuntimeException.","triggerScenarios":"scanForApplicationClass calls Thread.currentThread().getContextClassLoader().loadClass(applicationClass) and appClass.getConstructor().newInstance(), and any of those reflective steps throws.","commonSituations":"Application class has no public no-arg constructor; its constructor throws (e.g. depends on an uninitialized service); class references classes missing from the runtime classpath; classloader cannot see the class in the current thread context.","solutions":["Ensure the Application class has a public no-argument constructor.","Check the wrapped cause (getCause()) and fix the exception thrown inside the Application constructor.","Verify the Application class and everything it references are on the runtime classpath.","Remove heavy initialization from the constructor; keep it side-effect free."],"exampleFix":"// before\nclass MyApp extends Application {\n    MyApp(SomeService s) { ... } // no no-arg ctor\n}\n// after\nclass MyApp extends Application {\n    public MyApp() { }\n}","handlingStrategy":"try-catch","validationCode":"Class<?> c = Class.forName(appClassName, false, loader);\nif (!Application.class.isAssignableFrom(c)) throw new IllegalStateException(\"Not an Application\");\nif (c.getConstructors().length == 0 || java.lang.reflect.Modifier.isPublic(c.getModifiers()) == false)\n    throw new IllegalStateException(\"Application needs a public no-arg ctor\");","typeGuard":null,"tryCatchPattern":"try {\n    new MyApp();\n} catch (ExceptionInInitializerError | NoClassDefFoundError | InvocationTargetException e) {\n    log.error(\"Application class init failed\", e.getCause());\n}","preventionTips":["Give Application classes a public no-arg constructor","Keep constructors side-effect free","Log e.getCause() to find the real failure","Avoid referencing optional dependencies from Application classes"],"tags":["jaxrs","reflection","classloading","build-time"],"backgroundTag":"class-instantiation-failed","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"}