{"record":{"id":"fdedf0f98af68868","repo":"stanfordnlp/CoreNLP","slug":"class-is-in-classpath-multiple-times-canfill-ge","errorCode":null,"errorMessage":"Class is in classpath multiple times: ${canFill.get(name).getDeclaringClass().getCanonicalName()}","messagePattern":"Class is in classpath multiple times: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/util/ArgumentParser.java","lineNumber":393,"sourceCode":"          }\n          someOptionFilled = true;\n          //(required marker)\n          Pair<Boolean, Boolean> mark = Pair.makePair(false, false);\n          if (o.required()) {\n            mark = Pair.makePair(true, false);\n          }\n          //(add main name)\n          String name = o.name().toLowerCase();\n          if (name.isEmpty()) {\n            name = f.getName().toLowerCase();\n          }\n          if (canFill.containsKey(name)) {\n            String name1 = canFill.get(name).getDeclaringClass().getCanonicalName() + '.' + canFill.get(name).getName();\n            String name2 = f.getDeclaringClass().getCanonicalName() + '.' + f.getName();\n            if (!name1.equals(name2)) {\n              runtimeException(\"Multiple declarations of option \" + name + \": \" + name1 + \" and \" + name2);\n            } else {\n              err(\"Class is in classpath multiple times: \" + canFill.get(name).getDeclaringClass().getCanonicalName());\n            }\n          }\n          canFill.put(name, f);\n          required.put(name, mark);\n          interner.put(name, name);\n          //(add alternate names)\n          if ( ! o.alt().isEmpty()) {\n            for (String alt : o.alt().split(\" *, *\")) {\n              alt = alt.toLowerCase();\n              if (canFill.containsKey(alt) && !alt.equals(name))\n                throw new IllegalArgumentException(\"Multiple declarations of option \" + alt + \": \" + canFill.get(alt) + \" and \" + f);\n              canFill.put(alt, f);\n              if (mark.first) required.put(alt, mark);\n              interner.put(alt, name);\n            }\n          }\n        }\n      }","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/ArgumentParser.java#L375-L411","documentation":"ArgumentParser.fillOptionsImpl detects two different fields mapped to the same option name. If the declaring classes' canonical names differ it throws a hard error; when the names are identical (same class/field seen twice) it logs this err() message, indicating the class is on the classpath multiple times, then continues by overwriting the entry.","triggerScenarios":"Calling ArgumentParser.fillOptions / bootstrapMap with properties while the same options class is present twice on the classpath (duplicate jars), so reflection scans the same field twice under different Class objects.","commonSituations":"Shaded/fat jars plus the original jar both on the classpath; multiple CoreNLP versions in the classpath; duplicated dependencies after a build change.","solutions":["Run `mvn dependency:tree` or equivalent and remove the duplicate jar/version of the options class from the classpath","Deduplicate the classpath so each class appears exactly once","Check for the same library packaged both standalone and inside a fat jar","If duplicates are unavoidable, ignore this informational message since fill still succeeds"],"exampleFix":"// before\njava -cp corenlp.jar:lib/corenlp.jar:...   // corenlp classes twice\n// after\njava -cp corenlp.jar:...                    // single copy of each jar","handlingStrategy":"validation","validationCode":"Set<String> seen = new HashSet<>();\nfor (String jar : System.getProperty(\"java.class.path\").split(File.pathSeparator)) {\n  if (!seen.add(new File(jar).getName())) System.err.println(\"duplicate jar: \" + jar);\n}","typeGuard":null,"tryCatchPattern":"try {\n  ArgumentParser.fillOptions(cls, props, true);\n} catch (RuntimeException e) {\n  log.error(\"option fill failed: \" + e.getMessage());\n}","preventionTips":["Run dependency:tree / classpath analysis to detect duplicate artifacts","Never put a library both standalone and inside a shaded jar on the classpath","Treat this warning as a build hygiene signal and fix the classpath","Pin a single version of Stanford CoreNLP"],"tags":["java","classpath","configuration","reflection"],"backgroundTag":"conflicting-config-options","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}