{"record":{"id":"54fadc734a7eacca","repo":"quarkusio/quarkus","slug":"bean-target-does-not-declare-priority-and-inhe","errorCode":null,"errorMessage":"Bean ${target} does not declare @Priority and inherits multiple different priorities from stereotypes","messagePattern":"Bean (.+?) does not declare @Priority and inherits multiple different priorities from stereotypes","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java","lineNumber":413,"sourceCode":"    static Integer initStereotypeAlternativePriority(List<StereotypeInfo> stereotypes, AnnotationTarget target,\n            BeanDeployment beanDeployment) {\n        if (stereotypes.isEmpty()) {\n            return null;\n        }\n\n        Set<Integer> priorities = new HashSet<>();\n        for (StereotypeInfo stereotype : stereotypesWithTransitive(stereotypes, beanDeployment.getStereotypesMap())) {\n            if (stereotype.getAlternativePriority() != null) {\n                priorities.add(stereotype.getAlternativePriority());\n            }\n        }\n\n        if (priorities.isEmpty()) {\n            return null;\n        } else if (priorities.size() == 1) {\n            return priorities.iterator().next();\n        } else {\n            throw new DefinitionException(\"Bean \" + target\n                    + \" does not declare @Priority and inherits multiple different priorities from stereotypes\");\n        }\n    }\n\n    static String initStereotypeName(List<StereotypeInfo> stereotypes, AnnotationTarget target,\n            BeanDeployment beanDeployment) {\n        if (stereotypes.isEmpty()) {\n            return null;\n        }\n\n        for (StereotypeInfo stereotype : stereotypesWithTransitive(stereotypes, beanDeployment.getStereotypesMap())) {\n            if (stereotype.isNamed()) {\n                switch (target.kind()) {\n                    case CLASS:\n                        return getDefaultName(target.asClass());\n                    case FIELD:\n                        return target.asField().name();\n                    case METHOD:","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java#L395-L431","documentation":"An alternative bean's priority can come from @Priority or inherited from stereotypes. When the bean declares no @Priority and its stereotypes carry differing priority values, the priority is ambiguous, so ArC throws a DefinitionException instead of picking one arbitrarily.","triggerScenarios":"initStereotypeAlternativePriority collects priorities from the bean's stereotypes; the set has more than one distinct value and the bean (target) itself does not declare @Priority.","commonSituations":"Applying two stereotypes that each define @Priority with different values to an @Alternative bean; adding a second stereotype to an existing alternative without noticing the conflicting priorities; library stereotype updated its priority value.","solutions":["Declare @Priority explicitly on the bean class to override the stereotype priorities","Remove one of the conflicting stereotypes","Align the priority values defined in the stereotypes"],"exampleFix":"// before\n@Alternative\n@StereotypeA // @Priority(1000)\n@StereotypeB // @Priority(2000)\nclass MyBean { }\n// after\n@Alternative\n@Priority(2000)\n@StereotypeA\n@StereotypeB\nclass MyBean { }","handlingStrategy":"validation","validationCode":"// before applying two stereotypes to an @Alternative bean\nSet<Integer> prios = stereotypes.stream()\n        .map(s -> s.priority())\n        .filter(Objects::nonNull)\n        .collect(Collectors.toSet());\nif (prios.size() > 1 && beanClass.getAnnotation(Priority.class) == null) {\n    // fix: add explicit @Priority on the bean\n}","typeGuard":null,"tryCatchPattern":"try {\n    quarkusBuild.start();\n} catch (DefinitionException e) {\n    if (e.getMessage().contains(\"inherits multiple different priorities from stereotypes\")) {\n        logger.errorf(\"Declare @Priority on the alternative bean: %s\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Always declare @Priority explicitly on @Alternative beans using multiple stereotypes","Keep stereotype priority values consistent across the project","Document priority values in custom stereotypes"],"tags":["cdi","arc","alternative","priority","stereotypes"],"backgroundTag":"ambiguous-alternative-priority","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}