quarkusio/quarkus · error · DefinitionException

Bean ${target} does not declare @Priority and inherits multi

Error message

Bean ${target} does not declare @Priority and inherits multiple different priorities from stereotypes

What it means

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.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java:413

    static Integer initStereotypeAlternativePriority(List<StereotypeInfo> stereotypes, AnnotationTarget target,
            BeanDeployment beanDeployment) {
        if (stereotypes.isEmpty()) {
            return null;
        }

        Set<Integer> priorities = new HashSet<>();
        for (StereotypeInfo stereotype : stereotypesWithTransitive(stereotypes, beanDeployment.getStereotypesMap())) {
            if (stereotype.getAlternativePriority() != null) {
                priorities.add(stereotype.getAlternativePriority());
            }
        }

        if (priorities.isEmpty()) {
            return null;
        } else if (priorities.size() == 1) {
            return priorities.iterator().next();
        } else {
            throw new DefinitionException("Bean " + target
                    + " does not declare @Priority and inherits multiple different priorities from stereotypes");
        }
    }

    static String initStereotypeName(List<StereotypeInfo> stereotypes, AnnotationTarget target,
            BeanDeployment beanDeployment) {
        if (stereotypes.isEmpty()) {
            return null;
        }

        for (StereotypeInfo stereotype : stereotypesWithTransitive(stereotypes, beanDeployment.getStereotypesMap())) {
            if (stereotype.isNamed()) {
                switch (target.kind()) {
                    case CLASS:
                        return getDefaultName(target.asClass());
                    case FIELD:
                        return target.asField().name();
                    case METHOD:

View on GitHub (pinned to e1c734241f)

Solutions

  1. Declare @Priority explicitly on the bean class to override the stereotype priorities
  2. Remove one of the conflicting stereotypes
  3. Align the priority values defined in the stereotypes

Example fix

// before
@Alternative
@StereotypeA // @Priority(1000)
@StereotypeB // @Priority(2000)
class MyBean { }
// after
@Alternative
@Priority(2000)
@StereotypeA
@StereotypeB
class MyBean { }
Defensive patterns

Strategy: validation

Validate before calling

// before applying two stereotypes to an @Alternative bean
Set<Integer> prios = stereotypes.stream()
        .map(s -> s.priority())
        .filter(Objects::nonNull)
        .collect(Collectors.toSet());
if (prios.size() > 1 && beanClass.getAnnotation(Priority.class) == null) {
    // fix: add explicit @Priority on the bean
}

Try / catch

try {
    quarkusBuild.start();
} catch (DefinitionException e) {
    if (e.getMessage().contains("inherits multiple different priorities from stereotypes")) {
        logger.errorf("Declare @Priority on the alternative bean: %s", e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/54fadc734a7eacca. Report an issue: GitHub.