{"record":{"id":"0e8aa0e2fb361c1a","repo":"quarkusio/quarkus","slug":"inject-cannot-be-used-with-a-resteasyreactiv","errorCode":null,"errorMessage":"'@Inject' cannot be used with a '${ResteasyReactiveDotNames.APPLICATION}' class. Offending class is: '${selectedAppClass.name()}'","messagePattern":"'@Inject' cannot be used with a '(.+?)' class\\. Offending class is: '(.+?)'","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":96,"sourceCode":"        Set<String> singletonClasses = new HashSet<>();\n        Set<String> globalNameBindings = new HashSet<>();\n        boolean filterClasses = !excludedClasses.isEmpty();\n        Application application = null;\n        ClassInfo selectedAppClass = null;\n        BlockingDefault blocking = BlockingDefault.AUTOMATIC;\n        for (ClassInfo applicationClassInfo : applications) {\n            if (Modifier.isAbstract(applicationClassInfo.flags())) {\n                continue;\n            }\n            if (excludedClasses.contains(applicationClassInfo.name().toString())) {\n                continue;\n            }\n            if (selectedAppClass != null) {\n                throw new RuntimeException(\"More than one Application class: \" + applications);\n            }\n            selectedAppClass = applicationClassInfo;\n            if (appClassHasInject(selectedAppClass)) {\n                throw new RuntimeException(\"'@Inject' cannot be used with a '\" + ResteasyReactiveDotNames.APPLICATION\n                        + \"' class. Offending class is: '\" + selectedAppClass.name() + \"'\");\n            }\n            String applicationClass = applicationClassInfo.name().toString();\n            try {\n                Class<?> appClass = Thread.currentThread().getContextClassLoader().loadClass(applicationClass);\n                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());","sourceCodeStart":78,"sourceCodeEnd":114,"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#L78-L114","documentation":"The detected JAX-RS Application subclass declares a CDI @Inject field (or constructor), which RESTEasy Reactive does not support on Application classes. Application classes are instantiated reflectively by the scanner outside the CDI context, so injection cannot be performed.","triggerScenarios":"scanForApplicationClass finds an Application subclass where appClassHasInject(...) returns true, i.e. the class has @Inject annotated members.","commonSituations":"Injecting a config property or service into the Application class to compute getClasses()/getSingletons(); migrating a Quarkus (CDI-friendly) app to RESTEasy Reactive where the old pattern relied on injection.","solutions":["Remove @Inject members from the Application class and obtain needed values statically or via constructor parameters.","Move resource registration from the Application class to CDI beans (@Path resources discovered automatically) so no injection is needed.","Use org.eclipse.microprofile.config.ConfigProvider.getConfig() inside the Application instead of @Inject Config."],"exampleFix":"// before\nclass MyApp extends Application {\n    @Inject\n    MyService service;\n}\n// after\nclass MyApp extends Application {\n    private final MyService service = ConfigProvider.getConfig()\n            .getValue(\"my.service\", MyService.class);\n}","handlingStrategy":"validation","validationCode":"// before building\nfor (Field f : appClass.getDeclaredFields())\n    if (f.isAnnotationPresent(Inject.class))\n        throw new IllegalStateException(\"@Inject not allowed on Application class: \" + appClass.getName());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never annotate Application class members with @Inject","Use ConfigProvider.getConfig() for static config access in Application classes","Keep Application classes limited to getClasses()/getSingletons() overrides"],"tags":["jaxrs","cdi","resteasy-reactive","build-time"],"backgroundTag":"unsupported-cdi-injection","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"}