quarkusio/quarkus · error · io.quarkus.qute.TemplateException

The namespace [%s] is defined by multiple @TemplateData and/

Error message

The namespace [%s] is defined by multiple @TemplateData and/or @TemplateEnum annotations; make sure the annotation declared on the following classes do not collide:
	- <targets>

What it means

Thrown when the same namespace is declared by more than one @TemplateData or @TemplateEnum annotation. Qute maps a namespace to exactly one annotated target class so template expressions like {ns:member} resolve unambiguously.

Source

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

            }
            templateDataAnnotations.produce(new TemplateDataBuildItem(
                    new TemplateDataBuilder().annotationTarget(templateEnum.target()).namespace(TemplateData.SIMPLENAME)
                            .build(),
                    targetEnum));
        }

    }

    @BuildStep
    void validateTemplateDataNamespaces(List<TemplateDataBuildItem> templateData,
            BuildProducer<ServiceStartBuildItem> serviceStart) {

        Map<String, List<TemplateDataBuildItem>> namespaceToData = templateData.stream()
                .filter(TemplateDataBuildItem::hasNamespace)
                .collect(Collectors.groupingBy(TemplateDataBuildItem::getNamespace));
        for (Map.Entry<String, List<TemplateDataBuildItem>> e : namespaceToData.entrySet()) {
            if (e.getValue().size() > 1) {
                throw new TemplateException(
                        String.format(
                                "The namespace [%s] is defined by multiple @TemplateData and/or @TemplateEnum annotations; make sure the annotation declared on the following classes do not collide:\n\t- %s",
                                e.getKey(), e.getValue()
                                        .stream().map(TemplateDataBuildItem::getAnnotationInstance)
                                        .map(AnnotationInstance::target).map(Object::toString)
                                        .collect(Collectors.joining("\n\t- "))));
            }
        }
    }

    @BuildStep
    AutoAddScopeBuildItem addSingletonToNamedRecords() {
        return AutoAddScopeBuildItem.builder()
                .isAnnotatedWith(DotName.createSimple(Named.class))
                .and(this::isRecord)
                .defaultScope(BuiltinScope.SINGLETON)
                .reason("Found Java record annotated with @Named")
                .build();

View on GitHub (pinned to e1c734241f)

Solutions

  1. Rename the namespace in one of the annotations so each namespace maps to a single class
  2. Merge the annotated classes' needed members into one class and keep one namespace declaration
  3. Drop the redundant annotation if both declare the same intent
  4. Check dependencies' @TemplateData/@TemplateEnum namespaces before choosing a new namespace name

Example fix

// before
@TemplateEnum(value="cfg") enum A { }
@TemplateData(namespace="cfg") class B { }

// after
@TemplateEnum(value="cfg") enum A { }
@TemplateData(namespace="cfg2") class B { }
Defensive patterns

Strategy: validation

Validate before calling

// Ensure no namespace is claimed by more than one @TemplateData/@TemplateEnum
Set<String> seen = new HashSet<>();
for (String ns : allNamespaces) {
    if (!seen.add(ns)) { throw new IllegalStateException("Namespace reused: " + ns); }
}

Prevention

When it happens

Trigger: Two classes annotated with @TemplateEnum(value="configs") or @TemplateData(namespace="configs"); a @TemplateData namespace colliding with a @TemplateEnum namespace; introducing a new namespace string that already exists on another class.

Common situations: Grouping enums and value classes under one intuitive namespace name like 'time' or 'fmt'; copy-pasting a namespace string across classes; adding a @TemplateData for a class already covered by a shared library annotation with the same namespace.

Related errors


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