{"record":{"id":"cb2a049d3380f3fe","repo":"quarkusio/quarkus","slug":"multiple-generatedclassbuilditem-were-produced-for","errorCode":null,"errorMessage":"Multiple GeneratedClassBuildItem were produced for the same classes:\n\n${duplicates}","messagePattern":"Multiple GeneratedClassBuildItem were produced for the same classes:\n\n(.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/pkg/jar/AbstractJarBuilder.java","lineNumber":104,"sourceCode":"        this.jvmRequirements = jvmRequirements;\n\n        checkConsistency(generatedClasses);\n    }\n\n    private static void checkConsistency(List<GeneratedClassBuildItem> generatedClasses) {\n        Map<String, Long> generatedClassOccurrences = generatedClasses.stream()\n                .sorted(Comparator.comparing(GeneratedClassBuildItem::binaryName))\n                .collect(Collectors.groupingBy(GeneratedClassBuildItem::binaryName, Collectors.counting()));\n        StringBuilder duplicates = new StringBuilder();\n        for (Entry<String, Long> generatedClassOccurrence : generatedClassOccurrences.entrySet()) {\n            if (generatedClassOccurrence.getValue() < 2) {\n                continue;\n            }\n            duplicates.append(\"- \").append(generatedClassOccurrence.getKey()).append(\": \")\n                    .append(generatedClassOccurrence.getValue()).append(\"\\n\");\n        }\n        if (!duplicates.isEmpty()) {\n            throw new IllegalStateException(\n                    \"Multiple GeneratedClassBuildItem were produced for the same classes:\\n\\n\" + duplicates);\n        }\n    }\n\n    /**\n     * Copy files from {@code archive} to {@code fs}, filtering out service providers into the given map.\n     *\n     * @param archive the root application archive\n     * @param archiveCreator the archive creator\n     * @param services the services map\n     * @throws IOException if an error occurs\n     */\n    protected static void copyFiles(ApplicationArchive archive, ArchiveCreator archiveCreator,\n            Map<String, List<byte[]>> services,\n            Predicate<String> ignoredEntriesPredicate) throws IOException {\n        try {\n            Map<String, Path> pathsToCopy = new TreeMap<>();\n            archive.accept(tree -> {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/pkg/jar/AbstractJarBuilder.java#L86-L122","documentation":"AbstractJarBuilder.checkConsistency throws this IllegalStateException when multiple GeneratedClassBuildItem build items were produced for the same fully qualified class name during packaging. Duplicate generated classes would silently overwrite each other, so the jar builder detects duplicates and fails with a list of the offending classes and their producers.","triggerScenarios":"Two extensions (or two build steps) each producing a GeneratedClassBuildItem with the same class name in a single application build; checkConsistency groups generated classes by name and throws if any name occurs more than once.","commonSituations":"Using two third-party Quarkus extensions that generate the same support class; a custom build step that produces a class also generated by an extension; running a build with duplicated/old extension versions on the classpath.","solutions":["Identify the duplicate class and its producing steps from the list in the message.","Remove or rename one of the generators (change the generated class's package/name) so names are unique.","Resolve conflicting/duplicate extension versions in the dependency tree (mvn dependency:tree) and exclude the redundant extension."],"exampleFix":"// before (two build steps)\ngenerate(new GeneratedClassBuildItem(true, \"com.app.MyConfig\", bytes));\n// extension also generates com.app.MyConfig\n// after\ngenerate(new GeneratedClassBuildItem(true, \"com.app.MyCustomConfig\", bytes));","handlingStrategy":"validation","validationCode":"Map<String,Integer> seen = new HashMap<>();\nseen.merge(generatedClassName, 1, Integer::sum);\nif (seen.get(generatedClassName) > 1) {\n    throw new IllegalStateException(\"Generated class already produced: \" + generatedClassName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    buildJar();\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Multiple GeneratedClassBuildItem\")) {\n        LOG.error(\"Conflicting extensions generate the same class; review the listed producers and exclude one\");\n    }\n    throw e;\n}","preventionTips":["Namespace generated classes with a package unique to your extension.","Run mvn dependency:tree to detect duplicated/conflicting extensions.","In custom build steps, check whether a class was already generated before producing it."],"tags":["quarkus","packaging","build-time","duplicate-class"],"backgroundTag":"duplicate-build-item","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}