{"record":{"id":"13f24994c6e13766","repo":"quarkusio/quarkus","slug":"module-has-been-defined-twice-in-and","errorCode":null,"errorMessage":"Module '' has been defined twice, in:  and ","messagePattern":"Module '' has been defined twice, in:  and ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/packaging/modular/deployment/src/main/java/io/quarkus/modular/deployment/ModularitySteps.java","lineNumber":418,"sourceCode":"                                            e.getValue().stream().collect(\n                                                    Collectors.toMap(Function.identity(), ignored -> PackageAccess.OPEN))))\n                                    .toList());\n                        }\n                        // tabulate any used JDK modules.\n                        mi.dependencies().stream()\n                                .map(DependencyInfo::moduleName)\n                                .filter(n -> n.startsWith(\"java.\") || n.startsWith(\"jdk.\") || n.startsWith(\"ibm.\"))\n                                .forEach(usedJdkModuleNames::add);\n                        return mi;\n                    });\n            // Add the module to the index.\n            if (modulesByName.containsKey(moduleName)) {\n                ModuleInfo existing = modulesByName.get(moduleName);\n                if (existing.equals(depModule)) {\n                    // no harm; it's just in there twice for some reason\n                    continue;\n                }\n                throw new IllegalStateException(\"Module '\" + moduleName + \"' has been defined twice, in: \" +\n                        depModule.resolvedArtifact() + \" and \" + existing.resolvedArtifact());\n            }\n            modulesByName.put(moduleName, depModule);\n            // Warn about any split packages (temporary until #44657; then we don't care as much about it).\n            depModule.packages().keySet().forEach(pn -> {\n                String existing = modulesByPackageTemporary.putIfAbsent(pn, moduleName);\n                if (existing != null && !existing.equals(moduleName)) {\n                    log.warnf(\"Package %s is split, in %s and %s\", pn, existing, moduleName);\n                }\n            });\n        }\n\n        // Compute the set of extra app module dependencies from ArC component providers.\n        // todo: Remove once #52933 is sorted out.\n        for (String pn : extraAppModuleDepPackages) {\n            String moduleName = modulesByPackageTemporary.get(pn);\n            if (moduleName != null) {\n                extraDepsMap.computeIfAbsent(appModuleName, ModularitySteps::newMap)","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/packaging/modular/deployment/src/main/java/io/quarkus/modular/deployment/ModularitySteps.java#L400-L436","documentation":"While building the modularity model, ModularitySteps.buildModularityModel maps each module name to its ModuleInfo. If two different module descriptors (different resolved artifacts) claim the same module name, the build fails, since a JPMS module name must be unique. Identical duplicates are tolerated; only conflicting definitions throw.","triggerScenarios":"Two distinct artifacts on the class/module path both contain module-info with the same module name (e.g. an app module and an old version, or two jars defining the same Automatic-Module-Name/module name).","commonSituations":"Version conflicts resolved into multiple copies on the module path; a library renamed/repackaged under a new coordinate keeping the same module name; shading a module into another artifact without changing its name.","solutions":["Run mvn dependency:tree and exclude/remove the duplicate artifact providing the conflicting module","Bump or align versions so only one artifact with that module name is on the module path","If you shade/relocate a library, also change its module name in module-info or Automatic-Module-Name","Clean build to ensure stale artifacts are not being reused"],"exampleFix":"// before: two jars both declaring module com.example.lib\n<dependency>com.example:lib:1.0</dependency>\n<dependency>com.example:lib-shaded:1.0</dependency> <!-- same module name -->\n// after: exclude the duplicate\n<dependency>com.example:lib:1.0</dependency>","handlingStrategy":"validation","validationCode":"// detect duplicate module names across artifacts before the build step\nMap<String, List<Path>> byName = new HashMap<>();\nfor (ResolvedDependency d : deps) {\n    String name = readModuleName(d); // from module-info or Automatic-Module-Name\n    byName.computeIfAbsent(name, k -> new ArrayList<>()).add(d.resolvedArtifact());\n}\nbyName.forEach((name, artifacts) -> {\n    if (artifacts.size() > 1) throw new IllegalStateException(\"Duplicate module '\" + name + \"': \" + artifacts);\n});","typeGuard":null,"tryCatchPattern":"try {\n    buildModularityModel(...);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"defined twice\")) {\n        throw new IllegalStateException(\"Duplicate JPMS module name; run mvn dependency:tree and exclude the extra artifact\", e);\n    }\n    throw e;\n}","preventionTips":["Run mvn dependency:tree to spot duplicate library coordinates","Never shade a module into another artifact without changing its module name","Keep Automatic-Module-Name unique across your dependency set"],"tags":["jpms","duplicate-module","build"],"backgroundTag":"duplicate-module-name","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"}