{"record":{"id":"ac383b8c4ae9f1e2","repo":"quarkusio/quarkus","slug":"producer-method-must-not-have-an-observesasync-pa","errorCode":null,"errorMessage":"Producer method must not have an @ObservesAsync parameter (alternatively, async observer method must not be annotated @Produces): ","messagePattern":"Producer method must not have an @ObservesAsync parameter \\(alternatively, async observer method must not be annotated @Produces\\): ","errorType":"validation","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Injection.java","lineNumber":292,"sourceCode":"            MethodInfo producerMethod = beanTarget.asMethod();\n\n            if (beanDeployment.hasAnnotation(producerMethod, DotNames.INJECT)) {\n                throw new DefinitionException(\"Producer method must not be annotated @Inject \"\n                        + \"(alternatively, initializer method must not be annotated @Produces): \"\n                        + producerMethod);\n            }\n            if (Annotations.hasParameterAnnotation(beanDeployment, producerMethod, DotNames.DISPOSES)) {\n                throw new DefinitionException(\"Producer method must not have a @Disposes parameter \"\n                        + \"(alternatively, disposer method must not be annotated @Produces): \"\n                        + producerMethod);\n            }\n            if (Annotations.hasParameterAnnotation(beanDeployment, producerMethod, DotNames.OBSERVES)) {\n                throw new DefinitionException(\"Producer method must not have an @Observes parameter \"\n                        + \"(alternatively, observer method must not be annotated @Produces): \"\n                        + producerMethod);\n            }\n            if (Annotations.hasParameterAnnotation(beanDeployment, producerMethod, DotNames.OBSERVES_ASYNC)) {\n                throw new DefinitionException(\"Producer method must not have an @ObservesAsync parameter \"\n                        + \"(alternatively, async observer method must not be annotated @Produces): \"\n                        + producerMethod);\n            }\n\n            if (producerMethod.parameterTypes().isEmpty()) {\n                return Collections.emptyList();\n            }\n            // All parameters are injection points\n            List<Injection> injections = Collections.singletonList(new Injection(producerMethod,\n                    InjectionPointInfo.fromMethod(producerMethod, declaringBean.getImplClazz(), beanDeployment, transformer)));\n            validateInjections(injections, beanType);\n            return injections;\n        }\n        throw new IllegalArgumentException(\"Unsupported annotation target\");\n    }\n\n    static enum BeanType {\n        MANAGED_BEAN,","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Injection.java#L274-L310","documentation":"ArC rejects a producer method (@Produces) that declares an @ObservesAsync parameter. A method cannot simultaneously produce a bean and act as an asynchronous CDI observer; the spec forbids this dual role. Remove one of the two roles and split the logic into separate methods.","triggerScenarios":"Declaring a method annotated @Produces that has a parameter annotated @ObservesAsync; detected during bean discovery at build time by Injection.forBean.","commonSituations":"Copy-pasting observer logic into a producer method; refactoring an observer method to also expose its result as a bean; misunderstanding that producer methods may only have @Disposes-style special parameters, not observer parameters.","solutions":["Remove the @ObservesAsync parameter from the @Produces method and move the payload into a normal parameter or field","Split into two methods: one @Produces method for the bean, one separate @ObservesAsync observer method","If the intent was an observer, drop @Produces from the method"],"exampleFix":"// before\n@Produces\nvoid onEvent(@ObservesAsync Msg msg) {}\n// after\nvoid onEvent(@ObservesAsync Msg msg) {}\n@Produces\nString produce() { return \"x\"; }","handlingStrategy":"validation","validationCode":"boolean bad = java.lang.reflect.Modifier.isStatic(0);\nfor (Method m : MyClass.class.getDeclaredMethods()) {\n    if (m.isAnnotationPresent(Produces.class) &&\n        java.util.Arrays.stream(m.getParameterAnnotations()).flatMap(java.util.Arrays::stream)\n            .anyMatch(a -> a.annotationType().getSimpleName().equals(\"ObservesAsync\"))) {\n        throw new IllegalStateException(\"Producer with @ObservesAsync param: \" + m);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep producer methods free of any @Observes/@ObservesAsync parameters","Separate producer and observer concerns into distinct methods","Run a Quarkus dev-mode build early; ArC reports this at deployment time"],"tags":["cdi","arc","producer-method","observer"],"backgroundTag":"producer-observer-conflict","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"}