{"record":{"id":"f8a98b0b9ed8c0ab","repo":"stanfordnlp/CoreNLP","slug":"error-loading-flags-plaintextdocumentreaderandwrit","errorCode":null,"errorMessage":"Error loading flags.plainTextDocumentReaderAndWriter: '%s'","messagePattern":"Error loading flags\\.plainTextDocumentReaderAndWriter: '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java","lineNumber":266,"sourceCode":"   * Makes a DocumentReaderAndWriter based on\n   * flags.plainTextReaderAndWriter.  Useful for reading in\n   * untokenized text documents or reading plain text from the command\n   * line.  An example of a way to use this would be to return a\n   * edu.stanford.nlp.wordseg.Sighan2005DocumentReaderAndWriter for\n   * the Chinese Segmenter.\n   */\n  public static <INN extends CoreMap> DocumentReaderAndWriter<INN> makePlainTextReaderAndWriter(SeqClassifierFlags flags) {\n    String readerClassName = flags.plainTextDocumentReaderAndWriter;\n    // We set this default here if needed because there may be models\n    // which don't have the reader flag set\n    if (readerClassName == null) {\n      readerClassName = SeqClassifierFlags.DEFAULT_PLAIN_TEXT_READER;\n    }\n    DocumentReaderAndWriter<INN> readerAndWriter;\n    try {\n      readerAndWriter = ReflectionLoading.loadByReflection(readerClassName);\n    } catch (Exception e) {\n      throw new RuntimeException(String.format(\"Error loading flags.plainTextDocumentReaderAndWriter: '%s'\", flags.plainTextDocumentReaderAndWriter), e);\n    }\n    readerAndWriter.init(flags);\n    return readerAndWriter;\n  }\n\n  public DocumentReaderAndWriter<IN> makePlainTextReaderAndWriter() {\n    return makePlainTextReaderAndWriter(flags);\n  }\n\n  /**\n   * Returns the background class for the classifier.\n   *\n   * @return The background class name\n   */\n  public String backgroundSymbol() {\n    return flags.backgroundSymbol;\n  }\n","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java#L248-L284","documentation":"makePlainTextReaderAndWriter loads the plain-text DocumentReaderAndWriter class by reflection (defaulting to SeqClassifierFlags.DEFAULT_PLAIN_TEXT_READER when flags.plainTextDocumentReaderAndWriter is unset) and wraps any load failure in a RuntimeException naming the flag. Same failure modes as the general readerAndWriter loading.","triggerScenarios":"Calling makePlainTextReaderAndWriter() when flags.plainTextDocumentReaderAndWriter names a nonexistent class, a class without a no-arg constructor, or one that fails during reflective instantiation.","commonSituations":"Typo in the plainTextDocumentReaderAndWriter property; custom reader class not packaged in the deployed jar; copy-pasted fully-qualified class name with a mistake.","solutions":["Inspect the wrapped cause exception for the real load error","Unset the flag to fall back to SeqClassifierFlags.DEFAULT_PLAIN_TEXT_READER, or set it to a valid class like edu.stanford.nlp.objectbank.ObjectBank$LineSplittable... / PlainTextDocumentReaderAndWriter","Ensure the class is on the runtime classpath","Verify the class implements DocumentReaderAndWriter and has a public no-arg constructor"],"exampleFix":"// before\nplainTextDocumentReaderAndWriter = edu.stanford.nlp.PlarinTextDocumentReaderAndWriter\n// after\nplainTextDocumentReaderAndWriter = edu.stanford.nlp.ie.Platinum... -> use correct FQCN, e.g. remove the line to use the default","handlingStrategy":"try-catch","validationCode":"String cls = flags.plainTextDocumentReaderAndWriter != null ? flags.plainTextDocumentReaderAndWriter : SeqClassifierFlags.DEFAULT_PLAIN_TEXT_READER;\ntry { Class.forName(cls); } catch (ClassNotFoundException e) { throw new IllegalStateException(\"bad plainText reader class: \" + cls); }","typeGuard":null,"tryCatchPattern":"try { rw = classifier.makePlainTextReaderAndWriter(); }\ncatch (RuntimeException e) { log.error(\"Bad plainTextDocumentReaderAndWriter: {}\", e.getCause(), e); throw e; }","preventionTips":["Omit the flag to use the documented default reader","Validate class names at config load time","Keep custom readers in the deployed jar"],"tags":["reflection","classpath","config"],"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"}