{"record":{"id":"e5fd2c293806f755","repo":"stanfordnlp/CoreNLP","slug":"loading-postprocessorclass-failed-with-e-ge","errorCode":null,"errorMessage":"Loading: ${postProcessorClass} failed with: ${e.getMessage()}","messagePattern":"Loading: (.+?) failed with: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/TokenizerAnnotator.java","lineNumber":239,"sourceCode":"                                   LanguageInfo.getLanguageFromString(props.getProperty(\"tokenize.language\")));\n      }\n    } else if (props.getProperty(STANFORD_CDC_TOKENIZE + \".model\", null) != null) {\n      cdcAnnotator = new StatTokSentAnnotator(props);\n      segmenterAnnotator = null;\n    } else {\n      segmenterAnnotator = null;\n      cdcAnnotator = null;\n    }\n\n    // load any custom token post processing\n    String postProcessorClass = props.getProperty(\"tokenize.postProcessor\", \"\");\n    List<CoreLabelProcessor> processors = new ArrayList<>();\n    try {\n      if (!postProcessorClass.equals(\"\")) {\n        processors.add(ReflectionLoading.loadByReflection(postProcessorClass));\n      }\n    } catch (RuntimeException e) {\n      throw new RuntimeException(\"Loading: \"+postProcessorClass+\" failed with: \"+e.getMessage());\n    }\n    if (PropertiesUtils.getBool(props, \"tokenize.codepoint\")) {\n      processors.add(new CodepointCoreLabelProcessor());\n    }\n    postProcessors = Collections.unmodifiableList(processors);\n\n    VERBOSE = PropertiesUtils.getBool(props, \"tokenize.verbose\", verbose);\n    TokenizerType type = TokenizerType.getTokenizerType(props);\n    factory = initFactory(type, props, options);\n    if (VERBOSE) {\n      log.info(\"Initialized tokenizer factory: \" + factory);\n    }\n\n    if (PropertiesUtils.getBool(props, STANFORD_TOKENIZE + \".\" + STANFORD_CLEAN_XML)) {\n      this.cleanxmlAnnotator = new CleanXmlAnnotator(props);\n    } else {\n      this.cleanxmlAnnotator = null;\n    }","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/TokenizerAnnotator.java#L221-L257","documentation":"TokenizerAnnotator loads the 'tokenize.postprocessor' class via reflection (ReflectionLoading.loadByReflection). If the class cannot be found, instantiated, or its constructor throws, the wrapping catch rethrows it as a RuntimeException naming the class and the underlying message.","triggerScenarios":"Setting tokenize.postprocessor to a class name that is misspelled, not on the classpath, lacks a no-arg constructor, or whose constructor throws a RuntimeException during TokenizerAnnotator construction.","commonSituations":"Typo in fully-qualified class name; missing jar on classpath; custom CoreLabelProcessor whose constructor depends on unavailable resources; running under a different package layout after refactor.","solutions":["Verify the fully-qualified class name and that the class is on the runtime classpath.","Ensure the class implements CoreLabelProcessor and has an accessible no-argument constructor.","Instantiate the class directly in a test to see the real underlying exception.","Remove tokenize.postprocessor if a post-processor is not needed."],"exampleFix":"// before\nprops.setProperty(\"tokenize.postprocessor\", \"my.pkg.MyProcessor\");\n// after (class verified on classpath, implements CoreLabelProcessor, no-arg ctor)\nprops.setProperty(\"tokenize.postprocessor\", \"com.example.nlp.MyTokenPostProcessor\");","handlingStrategy":"try-catch","validationCode":"String cls = props.getProperty(\"tokenize.postprocessor\");\nif (cls != null && !cls.isEmpty()) {\n  try { Class.forName(cls); } catch (ClassNotFoundException e) { throw new IllegalStateException(\"tokenize.postprocessor not on classpath: \" + cls); }\n}","typeGuard":"boolean classExists(String name) { try { Class.forName(name); return true; } catch (Throwable t) { return false; } }","tryCatchPattern":"try { new TokenizerAnnotator(props); } catch (RuntimeException e) { log.error(\"Postprocessor load failed: \" + e.getMessage()); throw e; }","preventionTips":["Store fully-qualified class names in config, verified in CI","Ensure the jar containing the processor is in the runtime classpath image","Give custom processors no-arg constructors with no side effects"],"tags":["java","reflection","classpath","corenlp"],"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"}