{"record":{"id":"a4a95ce0b5ae83d1","repo":"quarkusio/quarkus","slug":"multiple-unequal-templatedata-declared-for-class","errorCode":null,"errorMessage":"Multiple unequal @TemplateData declared for <class>: <v> and <templateData>","messagePattern":"Multiple unequal @TemplateData declared for <class>: <v> and <templateData>","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java","lineNumber":3623,"sourceCode":"            }\n            if (targetClass == null) {\n                LOGGER.warnf(\"@TemplateData declared on %s is ignored: target %s it is not available in the index\",\n                        templateData.target(), targetClass);\n                continue;\n            }\n            uncontrolled.compute(targetClass.name(), (c, v) -> {\n                if (v == null) {\n                    return templateData;\n                }\n                if (!Objects.equals(v.value(ValueResolverGenerator.IGNORE),\n                        templateData.value(ValueResolverGenerator.IGNORE))\n                        || !Objects.equals(v.value(ValueResolverGenerator.PROPERTIES),\n                                templateData.value(ValueResolverGenerator.PROPERTIES))\n                        || !Objects.equals(v.value(ValueResolverGenerator.IGNORE_SUPERCLASSES),\n                                templateData.value(ValueResolverGenerator.IGNORE_SUPERCLASSES))\n                        || !Objects.equals(v.value(ValueResolverGenerator.NAMESPACE),\n                                templateData.value(ValueResolverGenerator.NAMESPACE))) {\n                    throw new IllegalStateException(\n                            \"Multiple unequal @TemplateData declared for \" + c + \": \" + v + \" and \" + templateData);\n                }\n                return v;\n            });\n            templateDataAnnotations.produce(new TemplateDataBuildItem(templateData, targetClass));\n        }\n\n        // Add synthetic @TemplateData for template enums\n        for (AnnotationInstance templateEnum : index.getAnnotations(Names.TEMPLATE_ENUM)) {\n            ClassInfo targetEnum = templateEnum.target().asClass();\n            if (!targetEnum.isEnum()) {\n                LOGGER.warnf(\"@TemplateEnum declared on %s is ignored: the target of this annotation must be an enum type\",\n                        targetEnum);\n                continue;\n            }\n            if (targetEnum.declaredAnnotation(ValueResolverGenerator.TEMPLATE_DATA) != null) {\n                LOGGER.debugf(\"@TemplateEnum declared on %s is ignored: enum is annotated with @TemplateData\", targetEnum);\n                continue;","sourceCodeStart":3605,"sourceCodeEnd":3641,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java#L3605-L3641","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Make all @TemplateData declarations for the target class use identical attributes","Remove the redundant @TemplateData declaration","If different members are needed, use one declaration listing all required members via value/properties instead of two conflicting ones","Search the codebase (and dependency annotations) for all references to the target class"],"exampleFix":"// before\n@TemplateData @TemplateData(target = BigDecimal.class, ignoreSuperclasses = true)\nclass Cfg { }\n\n// after\n@TemplateData(target = BigDecimal.class, ignoreSuperclasses = true)\nclass Cfg { } // single consistent declaration","handlingStrategy":"validation","validationCode":"// Ensure all @TemplateData declarations for a class share identical attributes\nMap<DotName, Set<AnnotationInstance>> byTarget = templateDataAnnotations.stream()\n    .collect(Collectors.groupingBy(TemplateDataBuildItem::getTargetClass,\n             Collectors.mapping(TemplateDataBuildItem::getAnnotationInstance, Collectors.toSet())));\nbyTarget.values().removeIf(s -> s.size() <= 1); // remaining = conflicts","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare @TemplateData for a class exactly once","Avoid mixing class-level and container-level @TemplateData for the same target","Grep the codebase for the target class name when adding a new @TemplateData","Check dependency annotations that may already expose the class"],"tags":["quarkus","qute","template-data","conflicting-annotations"],"backgroundTag":"duplicate-definition-collision","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}