stanfordnlp/CoreNLP · error · RuntimeException
Couldn't create POS tagger extractor class
Error message
Couldn't create POS tagger extractor class ${className} What it means
The rareExtractor(...) spec instantiates a custom Extractor subclass reflectively, exactly like extractor(...) in ExtractorFrames. Any failure to load, construct, or cast the named class is wrapped in this RuntimeException with the class name.
Solutions
- Confirm the fully-qualified class name and that its jar is on the classpath when training
- Ensure the class extends Extractor and exposes a public no-argument constructor
- Inspect the nested 'caused by' exception for the root cause (ClassNotFound vs instantiation vs constructor error)
- Instantiate the class directly in a test to validate it before referencing it in config
Example fix
// before
String rareExtractors = "...,rareExtractor(tagging.RareFeat),..."; // fails to load
// after
String rareExtractors = "...,rareExtractor(com.example.tagging.RareFeat),..."; // FQN + on classpath
public class RareFeat extends Extractor {
public RareFeat() { ... }
} Defensive patterns
Strategy: try-catch
Validate before calling
try {
Class<?> c = Class.forName(className);
if (!Extractor.class.isAssignableFrom(c)) throw new IllegalArgumentException(className + " is not an Extractor");
c.getDeclaredConstructor();
} catch (ClassNotFoundException | NoSuchMethodException e) {
throw new IllegalStateException("Rare extractor class not loadable: " + className, e);
} Try / catch
try {
ExtractorFramesRare.getExtractorFramesRare(spec);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Couldn't create POS tagger extractor class")) {
// check e.getCause() for the reflection root cause
} else { throw e; }
} Prevention
- Reference rare extractor classes by fully-qualified name and ship them on the training classpath
- Keep custom extractors extending Extractor with public no-arg constructors
- Verify with a direct 'new' instantiation in a test
- Keep the extractor compiled against the same tagger version you run
When it happens
Trigger: Passing rareExtractor(com.example.MyRareExtractor) where the class is missing from the classpath, lacks a public no-arg constructor, does not extend Extractor, or throws from its constructor.
Common situations: Forgetting to add your custom extractor jar to the training classpath; wrong package name after a refactor; class compiled against an incompatible tagger version.
Related errors
- Couldn't create POS tagger extractor class
- Error getting field value for
- Cannot get field from
- Loading: failed with
- can't open file
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/62fedbb3d0ca7afa.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/tagger/maxent/ExtractorFramesRare.java:379
}
} else if (arg.startsWith("distsimconjunction(")) {
String path = Extractor.getParenthesizedArg(arg, 1);
int lWindow = Extractor.getParenthesizedNum(arg, 2);
int rWindow = Extractor.getParenthesizedNum(arg, 3);
extrs.add(new ExtractorDistsimConjunction(path, lWindow, rWindow));
} else if (arg.equalsIgnoreCase("lctagfeatures")) {
extrs.addAll(Arrays.asList(lcTagFeatures(ttags)));
} else if (arg.equalsIgnoreCase("nonalphanumeric)")) {
extrs.add(new ExtractorNonAlphanumeric());
} else if (arg.equalsIgnoreCase("numeric)")) {
extrs.add(new ExtractorNumeric());
} else if (arg.startsWith("rareExtractor(")) {
String className = Extractor.getParenthesizedArg(arg, 1);
try {
Extractor e = (Extractor) Class.forName(className).getDeclaredConstructor().newInstance();
extrs.add(e);
} catch (Exception e) {
throw new RuntimeException("Couldn't create POS tagger extractor class " + className, e);
}
}
}
return extrs.toArray(Extractor.EMPTY_EXTRACTOR_ARRAY);
}
/**
* This provides the conjunction of various features as rare words features.
*
* @return An array of feature conjunctions
*/
private static Extractor[] naacl2003Conjunctions() {
Extractor[] newW = new Extractor[24];
//add them manually ....
newW[0] = new ExtractorsConjunction(cWordUppCase, cWordSuff1);
newW[1] = new ExtractorsConjunction(cWordUppCase, cWordSuff2);View on GitHub (pinned to 1b7edd19c4)