{"record":{"id":"62fedbb3d0ca7afa","repo":"stanfordnlp/CoreNLP","slug":"couldn-t-create-pos-tagger-extractor-class-class-62fedb","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/ExtractorFramesRare.java","lineNumber":379,"sourceCode":"        }\n      } else if (arg.startsWith(\"distsimconjunction(\")) {\n        String path = Extractor.getParenthesizedArg(arg, 1);\n        int lWindow = Extractor.getParenthesizedNum(arg, 2);\n        int rWindow = Extractor.getParenthesizedNum(arg, 3);\n        extrs.add(new ExtractorDistsimConjunction(path, lWindow, rWindow));\n      } else if (arg.equalsIgnoreCase(\"lctagfeatures\")) {\n        extrs.addAll(Arrays.asList(lcTagFeatures(ttags)));\n      } else if (arg.equalsIgnoreCase(\"nonalphanumeric)\")) {\n        extrs.add(new ExtractorNonAlphanumeric());\n      } else if (arg.equalsIgnoreCase(\"numeric)\")) {\n        extrs.add(new ExtractorNumeric());\n      } else if (arg.startsWith(\"rareExtractor(\")) {\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      }\n    }\n\n    return extrs.toArray(Extractor.EMPTY_EXTRACTOR_ARRAY);\n  }\n\n\n  /**\n   * This provides the conjunction of various features as rare words features.\n   *\n   * @return An array of feature conjunctions\n   */\n  private static Extractor[] naacl2003Conjunctions() {\n    Extractor[] newW = new Extractor[24];\n    //add them manually ....\n    newW[0] = new ExtractorsConjunction(cWordUppCase, cWordSuff1);\n    newW[1] = new ExtractorsConjunction(cWordUppCase, cWordSuff2);","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/tagger/maxent/ExtractorFramesRare.java#L361-L397","documentation":"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.","triggerScenarios":"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.","commonSituations":"Forgetting to add your custom extractor jar to the training classpath; wrong package name after a refactor; class compiled against an incompatible tagger version.","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"],"exampleFix":"// before\nString rareExtractors = \"...,rareExtractor(tagging.RareFeat),...\"; // fails to load\n// after\nString rareExtractors = \"...,rareExtractor(com.example.tagging.RareFeat),...\"; // FQN + on classpath\n\npublic class RareFeat extends Extractor {\n  public RareFeat() { ... }\n}","handlingStrategy":"try-catch","validationCode":"try {\n  Class<?> c = Class.forName(className);\n  if (!Extractor.class.isAssignableFrom(c)) throw new IllegalArgumentException(className + \" is not an Extractor\");\n  c.getDeclaredConstructor();\n} catch (ClassNotFoundException | NoSuchMethodException e) {\n  throw new IllegalStateException(\"Rare extractor class not loadable: \" + className, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  ExtractorFramesRare.getExtractorFramesRare(spec);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Couldn't create POS tagger extractor class\")) {\n    // check e.getCause() for the reflection root cause\n  } else { throw e; }\n}","preventionTips":["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"],"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"}