{"record":{"id":"776f2c2b1f6bd6d9","repo":"quarkusio/quarkus","slug":"class-classname-already-present-with-different","errorCode":null,"errorMessage":"Class ${className} already present with different class data","messagePattern":"Class (.+?) already present with different class data","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/index/LazyIndexer.java","lineNumber":101,"sourceCode":"     * {@code classData} will be used.\n     * <p>\n     * The given class and all annotations found on it will be indexed.\n     * Unlike the other {@code add} methods, superclasses will <em>not</em> be indexed.\n     * <p>\n     * If the same class name has already been added with <em>different</em> class data,\n     * an exception is thrown.\n     */\n    public void add(String className, byte[] classData) {\n        Objects.requireNonNull(className);\n        Objects.requireNonNull(classData);\n\n        // this shouldn't happen very often (hopefully...), but there is code out there\n        // that suggests a class name passed here may be an internal name, not a binary name\n        className = className.replace('/', '.');\n\n        byte[] existingData = classesData.get(className);\n        if (existingData != null && !Arrays.equals(existingData, classData)) {\n            throw new IllegalArgumentException(\"Class \" + className + \" already present with different class data\");\n        }\n\n        classNames.add(className);\n        classesData.put(className, classData);\n    }\n\n    /**\n     * Runs the indexing process. All classes added via {@code add()} are indexed\n     * and the {@link Result} is returned. If a class is not found in the class loader,\n     * an exception is thrown, unless it is a class of an annotation that is present\n     * on one of the previously indexed classes.\n     */\n    public Result complete() {\n        Indexer indexer = new Indexer();\n        Set<DotName> missingAnnotations = new HashSet<>();\n\n        Set<String> alreadySeen = new HashSet<>();\n","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/index/LazyIndexer.java#L83-L119","documentation":"LazyIndexer.add() caches raw class bytes by class name. If the same class name is added twice with different byte content, it throws this IllegalArgumentException, because the index cannot decide which definition is authoritative. The class name is normalized from internal '/' form to binary '.' form before the check.","triggerScenarios":"Calling LazyIndexer.add() (directly or via the indexer API) twice for the same class name but supplying different bytecode — e.g. two different jars/shadowed classes contain a class with the same fully-qualified name.","commonSituations":"Classpath contains duplicate classes from different versions of the same library (shading, fat jars, transitive dependency conflicts); a build tool registers both an old and a newly recompiled version of the same class in one augmentation run.","solutions":["Run mvn dependency:tree and exclude the duplicate dependency so only one version of the class exists on the deployment classpath","Check for shading/relocation conflicts (same package+class in two artifacts) and remove the offender","If you feed the LazyIndexer yourself, ensure each class name is added exactly once with the current bytecode","Do a clean rebuild to remove stale compiled copies of your own classes"],"exampleFix":"// before\n<dependency>\n  <groupId>com.acme</groupId><artifactId>acme-lib</artifactId><version>1.0</version>\n</dependency>\n<dependency>\n  <groupId>com.acme</groupId><artifactId>acme-lib-shaded</artifactId><version>1.0</version>\n</dependency>\n// after\n<dependency>\n  <groupId>com.acme</groupId><artifactId>acme-lib</artifactId><version>1.0</version>\n</dependency>\n<!-- shaded duplicate removed -->","handlingStrategy":"validation","validationCode":"// Deduplicate classes before feeding LazyIndexer\nMap<String, byte[]> unique = new HashMap<>();\nfor (var entry : classesByName) {\n    byte[] prev = unique.putIfAbsent(entry.name(), entry.bytes());\n    if (prev != null && !Arrays.equals(prev, entry.bytes())) {\n        throw new IllegalArgumentException(\"Duplicate class with different bytes: \" + entry.name());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    lazyIndexer.add(className, classData);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"already present with different class data\")) {\n        log.errorf(\"Duplicate class %s on classpath - run mvn dependency:tree to find the clash\", className);\n    }\n    throw e;\n}","preventionTips":["Run mvn dependency:tree and exclude duplicate/shaded artifacts","Never put two versions of the same library on the augmentation classpath","Avoid mixing fat jars and plain jars containing the same classes","Clean-build after changing module outputs"],"tags":["quarkus","indexing","duplicate-class","classpath"],"backgroundTag":"duplicate-class-on-classpath","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}