{"record":{"id":"988636aedf3ec78e","repo":"quarkusio/quarkus","slug":"producer-method-must-not-have-an-observes-paramet","errorCode":null,"errorMessage":"Producer method must not have an @Observes parameter (alternatively, observer method must not be annotated @Produces): ","messagePattern":"Producer method must not have an @Observes parameter \\(alternatively, 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":287,"sourceCode":"                }\n            }\n            validateInjections(injections, beanType);\n            return injections;\n        } else if (Kind.METHOD.equals(beanTarget.kind())) {\n            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        }","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Injection.java#L269-L305","documentation":"ArC throws this DefinitionException when a producer method declares a parameter annotated @Observes, or an observer method is annotated @Produces. Observer parameters are exclusive to observer methods; producer methods only accept plain injection parameters. forBean's METHOD branch validates producer parameters against OBSERVES.","triggerScenarios":"Declaring @Produces Foo produce(@Observes MyEvent e); caught by Annotations.hasParameterAnnotation(producerMethod, DotNames.OBSERVES) in forBean.","commonSituations":"Combining event-driven production with the producer API; copy-paste from an observer method; attempting lazy/event-based bean creation which CDI does not support via @Observes on producers.","solutions":["Remove @Observes from the producer method parameter","Add a dedicated observer method in the bean if event handling is needed","Pass any required dependencies as plain producer parameters (injection points)","Rebuild; failure occurs during Quarkus augmentation"],"exampleFix":"// before\n@Produces\nState state(@Observes RefreshEvent e) { return compute(); }\n\n// after\n@Produces\nState state() { return compute(); }\n\nvoid onRefresh(@Observes RefreshEvent e) { refresh(); }","handlingStrategy":"validation","validationCode":"void checkProducer(Method m) {\n    if (!m.isAnnotationPresent(jakarta.enterprise.inject.Produces.class)) return;\n    for (var p : m.getParameters()) {\n        if (p.isAnnotationPresent(jakarta.enterprise.event.Observes.class)) {\n            throw new IllegalStateException(\"@Observes on producer param: \" + m);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Observer and producer roles must live in separate methods","Producer parameters are injection points only — no event annotations","Handle events with dedicated @Observes methods in the same bean","Verify annotations after refactoring event listeners into producer classes"],"tags":["cdi","arc","observes","producer","bean-definition","build-time"],"backgroundTag":"cdi-bean-definition-invalid","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}