quarkusio/quarkus · error · java.lang.IllegalStateException

Multiple unequal @TemplateData declared for <class>: <v> and

Error message

Multiple unequal @TemplateData declared for <class>: <v> and <templateData>

What it means

Thrown when multiple unequal @TemplateData annotations resolve to the same target class (e.g. @TemplateData on a class plus a @TemplateData referencing it elsewhere, or on nested @TemplateData annotations). Qute merges repeated declarations but requires all attributes (value, properties, ignoreSuperclasses, namespace) to be identical; conflicting attributes fail the build.

Source

Thrown at extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java:3623

            }
            if (targetClass == null) {
                LOGGER.warnf("@TemplateData declared on %s is ignored: target %s it is not available in the index",
                        templateData.target(), targetClass);
                continue;
            }
            uncontrolled.compute(targetClass.name(), (c, v) -> {
                if (v == null) {
                    return templateData;
                }
                if (!Objects.equals(v.value(ValueResolverGenerator.IGNORE),
                        templateData.value(ValueResolverGenerator.IGNORE))
                        || !Objects.equals(v.value(ValueResolverGenerator.PROPERTIES),
                                templateData.value(ValueResolverGenerator.PROPERTIES))
                        || !Objects.equals(v.value(ValueResolverGenerator.IGNORE_SUPERCLASSES),
                                templateData.value(ValueResolverGenerator.IGNORE_SUPERCLASSES))
                        || !Objects.equals(v.value(ValueResolverGenerator.NAMESPACE),
                                templateData.value(ValueResolverGenerator.NAMESPACE))) {
                    throw new IllegalStateException(
                            "Multiple unequal @TemplateData declared for " + c + ": " + v + " and " + templateData);
                }
                return v;
            });
            templateDataAnnotations.produce(new TemplateDataBuildItem(templateData, targetClass));
        }

        // Add synthetic @TemplateData for template enums
        for (AnnotationInstance templateEnum : index.getAnnotations(Names.TEMPLATE_ENUM)) {
            ClassInfo targetEnum = templateEnum.target().asClass();
            if (!targetEnum.isEnum()) {
                LOGGER.warnf("@TemplateEnum declared on %s is ignored: the target of this annotation must be an enum type",
                        targetEnum);
                continue;
            }
            if (targetEnum.declaredAnnotation(ValueResolverGenerator.TEMPLATE_DATA) != null) {
                LOGGER.debugf("@TemplateEnum declared on %s is ignored: enum is annotated with @TemplateData", targetEnum);
                continue;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Make all @TemplateData declarations for the target class use identical attributes
  2. Remove the redundant @TemplateData declaration
  3. If different members are needed, use one declaration listing all required members via value/properties instead of two conflicting ones
  4. Search the codebase (and dependency annotations) for all references to the target class

Example fix

// before
@TemplateData @TemplateData(target = BigDecimal.class, ignoreSuperclasses = true)
class Cfg { }

// after
@TemplateData(target = BigDecimal.class, ignoreSuperclasses = true)
class Cfg { } // single consistent declaration
Defensive patterns

Strategy: validation

Validate before calling

// Ensure all @TemplateData declarations for a class share identical attributes
Map<DotName, Set<AnnotationInstance>> byTarget = templateDataAnnotations.stream()
    .collect(Collectors.groupingBy(TemplateDataBuildItem::getTargetClass,
             Collectors.mapping(TemplateDataBuildItem::getAnnotationInstance, Collectors.toSet())));
byTarget.values().removeIf(s -> s.size() <= 1); // remaining = conflicts

Prevention

When it happens

Trigger: A class annotated with @TemplateData is also listed as a target of another @TemplateData with different attribute values (different includeFilter/ignoreSuperclasses/namespace); two @TemplateData members of a @TemplateData.Container on the same target class with divergent settings.

Common situations: Adding @TemplateData on a bean that is already exposed via a container annotation elsewhere; tuning properties/namespace on one copy and forgetting the other; upgrading a dependency that newly carries @TemplateData for the same class.

Related errors


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