{"record":{"id":"dbf672342e385612","repo":"stanfordnlp/CoreNLP","slug":"couldn-t-create-pos-tagger-extractor-class-class","errorCode":null,"errorMessage":"Couldn't create POS tagger extractor class ${className}","messagePattern":"Couldn't create POS tagger extractor class (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/tagger/maxent/ExtractorFrames.java","lineNumber":280,"sourceCode":"        int lWindow = Extractor.getParenthesizedNum(arg, 1);\n        int rWindow = Extractor.getParenthesizedNum(arg, 2);\n        for (int i = lWindow; i <= rWindow; i++) {\n          extrs.add(new ExtractorWordShapeClassifier(i, \"chris4\"));\n        }\n      } else if (arg.startsWith(\"allunicodeshapeconjunction(\")) {\n        int lWindow = Extractor.getParenthesizedNum(arg, 1);\n        int rWindow = Extractor.getParenthesizedNum(arg, 2);\n        extrs.add(new ExtractorWordShapeConjunction(lWindow, rWindow, \"chris4\"));\n      } else if (arg.equalsIgnoreCase(\"spanishauxiliaries\")) {\n        extrs.add(new ExtractorSpanishAuxiliaryTag());\n        extrs.add(new ExtractorSpanishSemiauxiliaryTag());\n      } else if (arg.startsWith(\"extractor(\")) {\n        String className = Extractor.getParenthesizedArg(arg, 1);\n        try {\n          Extractor e = (Extractor) Class.forName(className).getDeclaredConstructor().newInstance();\n          extrs.add(e);\n        } catch (Exception e) {\n          throw new RuntimeException(\"Couldn't create POS tagger extractor class \" + className, e);\n        }\n      } else if (arg.equalsIgnoreCase(\"naacl2003unknowns\") ||\n                 arg.equalsIgnoreCase(\"lnaacl2003unknowns\") ||\n                 arg.equalsIgnoreCase(\"caselessnaacl2003unknowns\") ||\n                 arg.equalsIgnoreCase(\"naacl2003conjunctions\") ||\n                 arg.equalsIgnoreCase(\"frenchunknowns\") ||\n                 arg.equalsIgnoreCase(\"spanishunknowns\") ||\n                 arg.startsWith(\"wordshapes(\") ||\n                 arg.startsWith(\"wordshapeconjunction(\") ||\n                 arg.equalsIgnoreCase(\"motleyUnknown\") ||\n                 arg.startsWith(\"suffix(\") ||\n                 arg.startsWith(\"prefix(\") ||\n                 arg.startsWith(\"prefixsuffix\") ||\n                 arg.startsWith(\"capitalizationsuffix(\") ||\n                 arg.startsWith(\"distsim(\") ||\n                 arg.startsWith(\"distsimconjunction(\") ||\n                 arg.equalsIgnoreCase(\"lctagfeatures\") ||\n                 arg.startsWith(\"rareExtractor(\") ||","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/tagger/maxent/ExtractorFrames.java#L262-L298","documentation":"The extractor(...) spec instantiates a user-supplied Extractor subclass reflectively via Class.forName(...).newInstance(). If the class cannot be found, is not an Extractor, has no no-arg constructor, or its constructor throws, the exception is wrapped in this RuntimeException naming the class.","triggerScenarios":"Passing extractor(com.example.MyExtractor) where the class is not on the classpath, lacks a public no-argument constructor, does not extend Extractor, or throws in its constructor.","commonSituations":"Custom extractor jar missing from the runtime classpath; typo in the fully-qualified class name; extractor class written for a different CoreNLP version with an incompatible Extractor signature; abstract or constructor-failing class.","solutions":["Verify the fully-qualified class name is spelled correctly and the class is on the classpath at runtime","Ensure the class extends edu.stanford.nlp.tagger.maxent.Extractor and has a public no-argument constructor","Read the 'caused by' exception in the stack trace to distinguish ClassNotFoundException from InstantiationException or constructor failures","Test instantiating the class with a plain 'new MyExtractor()' in a unit test before wiring it into the tagger config"],"exampleFix":"// before\nString extractors = \"...,extractor(MyExtractor),...\"; // not found\n// after (fully qualified, on classpath, public no-arg ctor)\nString extractors = \"...,extractor(com.example.tagging.MyExtractor),...\";\n\n// class must look like:\npublic class MyExtractor extends Extractor {\n  public MyExtractor() { super(...); }\n}","handlingStrategy":"try-catch","validationCode":"try {\n  Class<?> c = Class.forName(className);\n  if (!Extractor.class.isAssignableFrom(c)) throw new IllegalArgumentException(className + \" does not extend Extractor\");\n  c.getDeclaredConstructor(); // fails fast if no no-arg ctor\n} catch (ClassNotFoundException | NoSuchMethodException e) {\n  throw new IllegalStateException(\"Extractor class not loadable: \" + className, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  ExtractorFrames.getExtractorFrames(spec);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Couldn't create POS tagger extractor class\")) {\n    // inspect e.getCause(): ClassNotFoundException vs ctor failure\n  } else { throw e; }\n}","preventionTips":["Use fully-qualified class names in extractor(...) specs","Ensure the custom extractor jar ships with the runtime, not just the build classpath","Give custom Extractor classes public no-argument constructors","Smoke-test reflective instantiation in CI before training"],"tags":["java","reflection","class-not-found","pos-tagger"],"backgroundTag":"class-not-found","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"}