{"record":{"id":"baf41c16ab061a7a","repo":"quarkusio/quarkus","slug":"method-method-of-class-beanclass-is-not-a-pr","errorCode":null,"errorMessage":"Method ${method} of class ${beanClass} is not a producer method, but is annotated with a stereotype: ${stereotype}","messagePattern":"Method (.+?) of class (.+?) is not a producer method, but is annotated with a stereotype: (.+?)","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java","lineNumber":1255,"sourceCode":"            ClassInfo aClass = beanClass;\n            Set<MethodSignatureKey> methods = new HashSet<>();\n            while (aClass != null) {\n                for (MethodInfo method : aClass.methods()) {\n                    MethodSignatureKey methodKey = method.signatureKey();\n                    if (method.isSynthetic() || Methods.isOverridden(methodKey, methods)) {\n                        continue;\n                    }\n                    methods.add(methodKey);\n                    Collection<AnnotationInstance> methodAnnotations = annotationStore.getAnnotations(method);\n                    if (methodAnnotations.isEmpty()) {\n                        continue;\n                    }\n                    // Verify that non-producer methods are not annotated with stereotypes\n                    // only account for 'real' stereotypes that are not additional BeanDefiningAnnotations\n                    if (!annotationStore.hasAnnotation(method, DotNames.PRODUCES)) {\n                        for (AnnotationInstance i : methodAnnotations) {\n                            if (realStereotypes.contains(i.name())) {\n                                throw new DefinitionException(\n                                        \"Method \" + method + \" of class \" + beanClass\n                                                + \" is not a producer method, but is annotated \" +\n                                                \"with a stereotype: \" + i.name().toString());\n                            }\n                        }\n                    }\n                    if (annotationStore.hasAnnotation(method, DotNames.OBSERVES)) {\n                        syncObserverMethods.computeIfAbsent(method, ignored -> new HashSet<>())\n                                .add(beanClass);\n                        // add only concrete classes\n                        if (!Modifier.isAbstract(beanClass.flags())) {\n                            // do not register classes with observers and no bean def. annotation as beans in strict mode\n                            if (!strictCompatibility) {\n                                beanClasses.add(beanClass);\n                                if (!hasBeanDefiningAnnotation) {\n                                    LOGGER.debugf(\n                                            \"Observer method found but %s has no bean defining annotation - using @Dependent\",\n                                            beanClass);","sourceCodeStart":1237,"sourceCodeEnd":1273,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java#L1237-L1273","documentation":"This is a ArC (Quarkus CDI) DefinitionException thrown during bean discovery. CDI stereotypes (annotation types annotated @Stereotype) may only be applied to beans and producer methods/fields. Applying a real stereotype to a regular method that is not a producer method is invalid, so the container rejects the deployment.","triggerScenarios":"A method on a bean-defining class carries a stereotype annotation (from a registered @Stereotype) but is not annotated @Produces; BeanDeployment.deploy/bean registration scans method annotations and finds the stereotype in realStereotypes (excluding additional BeanDefiningAnnotations).","commonSituations":"Copying a stereotype like @Transactional or a custom @Stereotype onto a private helper or initializer method; a refactoring removed @Produces but left the stereotype; misunderstanding stereotypes as generic markers applicable anywhere.","solutions":["Remove the stereotype annotation from the non-producer method, or annotate it as a stereotype meta-annotation only on classes.","If the method was meant to produce a bean, add @Produces so the stereotype becomes legal.","If you authored the stereotype, re-check its @Target (it should target TYPE/FIELD/METHOD as intended) and restrict usage."],"exampleFix":"// before\nclass Repo {\n  @Transactional\n  User findUser(long id) { ... } // not a producer\n}\n// after\nclass Repo {\n  @Produces\n  @Transactional\n  User findUser(long id) { ... }\n}\n// or simply remove @Transactional","handlingStrategy":"validation","validationCode":"// Before build/deploy: reject stereotypes on non-producer methods\nif (method.isAnnotationPresent(StereotypeDerived.class) && !method.isAnnotationPresent(Produces.class)) {\n    throw new IllegalStateException(\"Stereotype on non-producer method: \" + method);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only apply stereotypes to classes or producer members","Restrict stereotype @Target meta-annotation appropriately","Run a Quarkus dev-mode compile early to catch discovery errors fast"],"tags":["cdi","quarkus-arc","stereotype","bean-discovery"],"backgroundTag":"stereotype-on-non-producer","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"}