{"record":{"id":"dc321d304357651f","repo":"quarkusio/quarkus","slug":"no-producer-method-or-field-declared-by-the-bean-c","errorCode":null,"errorMessage":"No producer method or field declared by the bean class that is assignable to the disposed parameter of a disposer method: ${disposerMethod}","messagePattern":"No producer method or field declared by the bean class that is assignable to the disposed parameter of a disposer method: (.+?)","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java","lineNumber":1432,"sourceCode":"        // that are used, clearly a matching producer bean exists for those\n        for (DisposerInfo unusedDisposer : unusedDisposers) {\n            Type disposedParamType = unusedDisposer.getDisposedParameterType();\n            boolean matchingProducerBeanExists = false;\n            scan: for (BeanInfo bean : beans) {\n                if (bean.isProducer()) {\n                    if (!bean.getDeclaringBean().equals(unusedDisposer.getDeclaringBean())) {\n                        continue;\n                    }\n                    for (Type beanType : bean.getTypes()) {\n                        if (beanResolver.matches(disposedParamType, beanType)) {\n                            matchingProducerBeanExists = true;\n                            break scan;\n                        }\n                    }\n                }\n            }\n            if (!matchingProducerBeanExists) {\n                throw new DefinitionException(\"No producer method or field declared by the bean class that is assignable \"\n                        + \"to the disposed parameter of a disposer method: \" + unusedDisposer.getDisposerMethod());\n            }\n        }\n\n        for (Entry<MethodInfo, Set<ClassInfo>> entry : syncObserverMethods.entrySet()) {\n            registerObserverMethods(entry.getValue(), observers, injectionPoints,\n                    beanClassToBean, entry.getKey(), false, observerTransformers, jtaCapabilities);\n        }\n\n        for (Entry<MethodInfo, Set<ClassInfo>> entry : asyncObserverMethods.entrySet()) {\n            registerObserverMethods(entry.getValue(), observers, injectionPoints,\n                    beanClassToBean, entry.getKey(), true, observerTransformers, jtaCapabilities);\n        }\n\n        if (LOGGER.isTraceEnabled()) {\n            for (BeanInfo bean : beans) {\n                LOGGER.logf(Level.TRACE, \"Created %s\", bean);\n            }","sourceCodeStart":1414,"sourceCodeEnd":1450,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java#L1414-L1450","documentation":"Every disposer method must correspond to a producer method or field declared by the same bean class, matching the disposed parameter type (assignable, with qualifiers). If a disposer is found whose disposed parameter matches no producer of its declaring bean, ArC throws this DefinitionException during bean registration.","triggerScenarios":"A @Disposes-annotated parameter's type/qualifiers cannot be matched to any @Produces method/field in the same class — e.g. the disposer references a producer that was deleted, moved to another class, renamed qualifiers, or is vetoed.","commonSituations":"Removing a producer method but keeping its disposer; moving producer/disposer pairs apart across classes; qualifier changes making the disposed parameter non-matching; unusedDisposer scan during deployment.","solutions":["Restore or re-add the matching @Produces method/field in the same bean class.","Move the disposer into the class that declares the producer.","Align the disposed parameter's type and qualifiers with the producer's.","Delete the orphaned disposer method if it is no longer needed."],"exampleFix":"// before\nclass Cfg {\n  @Disposes\n  void close(Conn c) { c.close(); } // no producer for Conn here\n}\n// after\nclass Cfg {\n  @Produces\n  Conn connect() { return new Conn(); }\n  @Disposes\n  void close(Conn c) { c.close(); }\n}","handlingStrategy":"validation","validationCode":"// Keep producer/disposer pairs in the same class; assert at build time\nfor (Method m : cls.getDeclaredMethods()) {\n    if (Arrays.stream(m.getParameterAnnotations()).flatMap(Stream::of)\n            .anyMatch(a -> a instanceof Disposes.class)\n            && Arrays.stream(cls.getDeclaredMethods()).noneMatch(p -> p.isAnnotationPresent(Produces.class))) {\n        throw new IllegalStateException(\"Disposer without producer in \" + cls);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always co-locate @Produces and @Disposes in the same class","When deleting a producer, search for and remove its disposer","Keep disposed parameter type/qualifiers identical to the produced type"],"tags":["cdi","quarkus-arc","disposer","producer"],"backgroundTag":"orphaned-disposer-method","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"}