stanfordnlp/CoreNLP · warning

Class is in classpath multiple times

Error message

Class is in classpath multiple times: ${canFill.get(name).getDeclaringClass().getCanonicalName()}

What it means

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.

Solutions

  1. Run `mvn dependency:tree` or equivalent and remove the duplicate jar/version of the options class from the classpath
  2. Deduplicate the classpath so each class appears exactly once
  3. Check for the same library packaged both standalone and inside a fat jar
  4. If duplicates are unavoidable, ignore this informational message since fill still succeeds

Example fix

// before
java -cp corenlp.jar:lib/corenlp.jar:...   // corenlp classes twice
// after
java -cp corenlp.jar:...                    // single copy of each jar
Defensive patterns

Strategy: validation

Validate before calling

Set<String> seen = new HashSet<>();
for (String jar : System.getProperty("java.class.path").split(File.pathSeparator)) {
  if (!seen.add(new File(jar).getName())) System.err.println("duplicate jar: " + jar);
}

Try / catch

try {
  ArgumentParser.fillOptions(cls, props, true);
} catch (RuntimeException e) {
  log.error("option fill failed: " + e.getMessage());
}

Prevention

When it happens

Trigger: 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.

Common situations: Shaded/fat jars plus the original jar both on the classpath; multiple CoreNLP versions in the classpath; duplicated dependencies after a build change.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/fdedf0f98af68868. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/util/ArgumentParser.java:393

          }
          someOptionFilled = true;
          //(required marker)
          Pair<Boolean, Boolean> mark = Pair.makePair(false, false);
          if (o.required()) {
            mark = Pair.makePair(true, false);
          }
          //(add main name)
          String name = o.name().toLowerCase();
          if (name.isEmpty()) {
            name = f.getName().toLowerCase();
          }
          if (canFill.containsKey(name)) {
            String name1 = canFill.get(name).getDeclaringClass().getCanonicalName() + '.' + canFill.get(name).getName();
            String name2 = f.getDeclaringClass().getCanonicalName() + '.' + f.getName();
            if (!name1.equals(name2)) {
              runtimeException("Multiple declarations of option " + name + ": " + name1 + " and " + name2);
            } else {
              err("Class is in classpath multiple times: " + canFill.get(name).getDeclaringClass().getCanonicalName());
            }
          }
          canFill.put(name, f);
          required.put(name, mark);
          interner.put(name, name);
          //(add alternate names)
          if ( ! o.alt().isEmpty()) {
            for (String alt : o.alt().split(" *, *")) {
              alt = alt.toLowerCase();
              if (canFill.containsKey(alt) && !alt.equals(name))
                throw new IllegalArgumentException("Multiple declarations of option " + alt + ": " + canFill.get(alt) + " and " + f);
              canFill.put(alt, f);
              if (mark.first) required.put(alt, mark);
              interner.put(alt, name);
            }
          }
        }
      }

View on GitHub (pinned to 1b7edd19c4)