stanfordnlp/CoreNLP · warning

Could not set option

Error message

Could not set option: ${entry.getKey()}; either the option is mistyped, not defined, or the class ${className} does not exist.

What it means

For dotted keys under ensureAllOptions, ArgumentParser loads the class named by the key prefix via the system classloader. If ClassLoader.loadClass throws, it reports that the option is mistyped, not defined, or the class does not exist, then skips the key.

Solutions

  1. Verify the class name prefix matches a loadable class on the runtime classpath (check spelling and package)
  2. Use '$' for inner classes: edu.stanford.nlp.util.ArgumentParser$Options.field
  3. Add the missing jar/module to the classpath
  4. Re-derive the option key from the actual class canonical name

Example fix

// before
edu.stanford.nlp.pipeline.StanfordCoreNLP.Options.verbose=true  // wrong: Options is inner
// after
edu.stanford.nlp.pipeline.StanfordCoreNLP$AnnotatorOptions.verbose=true
Defensive patterns

Strategy: validation

Validate before calling

String cls = key.substring(0, key.lastIndexOf('.'));
try { Class.forName(cls); } catch (ClassNotFoundException e) {
  throw new IllegalArgumentException("option class not loadable: " + cls);
}

Try / catch

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

Prevention

When it happens

Trigger: Property key like 'com.example.MyClass.option=x' where com.example.MyClass is not loadable (wrong package, class not on classpath, inner-class name written with '.' instead of '$').

Common situations: Renamed/moved classes after an upgrade; missing jar; inner classes addressed with dots instead of $ separators; typos in package names.

Related errors


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

Appendix: source

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

      if (target != null) {
        // (case: declared option)
        fillField(class2object.get(target.getDeclaringClass()), target, value);
      } else if (ensureAllOptions) {
        // (case: undeclared option)
        // split the key
        int lastDotIndex = rawKeyStr.lastIndexOf('.');
        if (lastDotIndex < 0) {
          err("Unrecognized option: " + key);
          continue;
        }
        if (!rawKeyStr.startsWith("log.")) {  // ignore Redwood options
          String className = rawKeyStr.substring(0, lastDotIndex);
          // get the class
          Class clazz = null;
          try {
            clazz = ClassLoader.getSystemClassLoader().loadClass(className);
          } catch (Exception e) {
            err("Could not set option: " + entry.getKey() + "; either the option is mistyped, not defined, or the class " + className + " does not exist.");
          }
          // get the field
          if (clazz != null) {
            String fieldName = rawKeyStr.substring(lastDotIndex + 1);
            try {
              target = clazz.getField(fieldName);
            } catch (Exception e) {
              err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className);
            }
            if (target != null) {
              log("option overrides " + target + " to '" + value + '\'');
              fillField(class2object.get(target.getDeclaringClass()), target, value);
            } else {
              err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className);
            }
          }
        }
      }

View on GitHub (pinned to 1b7edd19c4)