stanfordnlp/CoreNLP · warning
Could not set option
Error message
Could not set option: ${entry.getKey()}; no such field: ${fieldName} in class: ${className} What it means
After the class resolves, ArgumentParser calls clazz.getField(fieldName) to locate the option field; if no such public field exists it logs this err() message. A second identical message is logged later if target is still null.
Solutions
- Check the exact public field name on the target class (Java is case-sensitive) and correct the key
- Only public static fields declared with @Argument can be filled; make sure the field qualifies
- Consult the target class source/javadoc for valid option names
- Remove the stale key if the option no longer exists
Example fix
// before edu.stanford.nlp.pipeline.StanfordCoreNLP.maxSentenceLenght=100 // typo // after edu.stanford.nlp.pipeline.StanfordCoreNLP.maxSentenceLength=100
Defensive patterns
Strategy: validation
Validate before calling
int dot = key.lastIndexOf('.');
Class<?> c = Class.forName(key.substring(0, dot));
String field = key.substring(dot + 1);
boolean ok = java.util.Arrays.stream(c.getFields())
.anyMatch(f -> f.getName().equals(field));
if (!ok) throw new IllegalArgumentException("no such option field: " + key); Try / catch
try {
ArgumentParser.fillOptions(cls, props, true);
} catch (RuntimeException e) {
log.error("invalid option field: " + e.getMessage());
} Prevention
- Copy field names directly from class source/javadoc, never by memory
- Remember Java field-name case sensitivity
- Only target public static option fields
- Re-check keys after upgrading the library (fields get renamed)
When it happens
Trigger: Key 'some.Class.foo=x' where Class loads but has no public field named 'foo' (typo, non-public field, renamed field).
Common situations: Upgrading CoreNLP and referencing fields that were renamed/removed; writing lowercase/uppercase mismatch in field names; pointing at a class that was never a valid options holder.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Class is in classpath multiple times
- Could not set option
- Both parse.model and parse.executable properties must be…
- Can only create a model using this method if…
- Cannot cast " + classname + " into " + type.getName()
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/65c37c36b64504a1.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/util/ArgumentParser.java:458
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);
}
}
}
}
}
//--Ensure Required
boolean good = true;
for (Map.Entry<String, Pair<Boolean, Boolean>> entry : required.entrySet()) {
String key = entry.getKey();
Pair<Boolean, Boolean> mark = entry.getValue();
if (mark.first && !mark.second) {View on GitHub (pinned to 1b7edd19c4)