{"record":{"id":"5dd93dde6bcae80d","repo":"quarkusio/quarkus","slug":"more-than-1-parameter-of-type-beaninfo-or-observer","errorCode":null,"errorMessage":"More than 1 parameter of type BeanInfo or ObserverInfo for method \" + method","messagePattern":"More than 1 parameter of type BeanInfo or ObserverInfo for method \" \\+ method","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionPhaseRegistration.java","lineNumber":56,"sourceCode":"        int numQueryParameters = 0;\n        List<ExtensionMethodParameter> parameters = new ArrayList<>(method.parametersCount());\n        for (org.jboss.jandex.Type parameterType : method.parameterTypes()) {\n            ExtensionMethodParameter parameter = ExtensionMethodParameter.of(parameterType);\n            parameters.add(parameter);\n\n            if (parameter.isQuery()) {\n                numQueryParameters++;\n            }\n\n            parameter.verifyAvailable(ExtensionPhase.REGISTRATION, method);\n        }\n\n        if (numQueryParameters == 0) {\n            throw new DefinitionException(\"No parameter of type BeanInfo or ObserverInfo for method \" + method);\n        }\n\n        if (numQueryParameters > 1) {\n            throw new DefinitionException(\"More than 1 parameter of type BeanInfo or ObserverInfo for method \" + method);\n        }\n\n        ExtensionMethodParameter query = parameters.stream()\n                .filter(ExtensionMethodParameter::isQuery)\n                .findAny()\n                .get(); // guaranteed to be there\n\n        List<?> allValuesForQueryParameter = Collections.emptyList();\n        if (query == ExtensionMethodParameter.BEAN_INFO) {\n            allValuesForQueryParameter = matchingBeans(method.jandex, false);\n        } else if (query == ExtensionMethodParameter.INTERCEPTOR_INFO) {\n            allValuesForQueryParameter = matchingBeans(method.jandex, true);\n        } else if (query == ExtensionMethodParameter.OBSERVER_INFO) {\n            allValuesForQueryParameter = matchingObservers(method.jandex);\n        }\n\n        for (Object queryParameterValue : allValuesForQueryParameter) {\n            List<Object> arguments = new ArrayList<>();","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionPhaseRegistration.java#L38-L74","documentation":"Each build-time @Registration extension method may declare only one query parameter — a single BeanInfo or ObserverInfo identifying the target of the registration. ExtensionPhaseRegistration.runExtensionMethod() throws DefinitionException when more than one such parameter is present, since a method registers exactly one bean or observer per invocation.","triggerScenarios":"Declaring an @Registration method with both a BeanInfo and an ObserverInfo parameter (or two BeanInfo parameters), making numQueryParameters > 1 when Arc processes the extension.","commonSituations":"Trying to register a bean and its observer in a single callback; adding an extra BeanInfo parameter hoping to see related beans; copy-paste from a synthesis-phase method with different rules.","solutions":["Keep exactly one BeanInfo or ObserverInfo parameter and remove the other.","Split into two @Registration methods — one for the bean, one for the observer.","If you need related metadata, derive it from the single query parameter rather than adding extra info parameters."],"exampleFix":"// before\n@Registration\nvoid register(BeanInfo bean, ObserverInfo observer) { ... }\n\n// after\n@Registration\nvoid registerBean(BeanInfo bean) { ... }\n\n@Registration\nvoid registerObserver(ObserverInfo observer) { ... }","handlingStrategy":"validation","validationCode":"long targets = Arrays.stream(method.getParameters())\n    .map(p -> p.type().name().withoutPackagePrefix())\n    .filter(n -> n.equals(\"BeanInfo\") || n.equals(\"ObserverInfo\"))\n    .count();\nif (targets > 1) throw new IllegalStateException(\"@Registration method must take exactly one BeanInfo or ObserverInfo\");","typeGuard":"static boolean isSingleTargetRegistration(MethodInfo m) {\n    return Arrays.stream(m.parameters()).filter(p ->\n        Set.of(\"BeanInfo\",\"ObserverInfo\").contains(p.type().name().withoutPackagePrefix())).count() == 1;\n}","tryCatchPattern":"try {\n    processor.run(extensionClass);\n} catch (DefinitionException e) {\n    fail(\"Multiple registration targets: \" + e.getMessage());\n}","preventionTips":["One registration target per @Registration method; use separate methods for beans vs observers.","Derive related metadata from the single target parameter.","Review extension signatures against the 'exactly one query parameter' rule."],"tags":["arc","cdi","build-time-extension","quarkus"],"backgroundTag":"duplicate-extension-query-parameter","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"}