{"record":{"id":"7b0e595202c9b922","repo":"stanfordnlp/CoreNLP","slug":"error-loading","errorCode":null,"errorMessage":"error loading ","messagePattern":"error loading ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFClassifier.java","lineNumber":2987,"sourceCode":"\n    if (crf.flags.useEmbedding && crf.flags.embeddingWords != null && crf.flags.embeddingVectors != null) {\n      crf.readEmbeddingsData();\n    }\n\n    if (crf.flags.loadClassIndexFrom != null) {\n      crf.classIndex = loadClassIndexFromFile(crf.flags.loadClassIndexFrom);\n    }\n\n    if (loadPath != null) {\n      crf.loadClassifierNoExceptions(loadPath, props);\n    } else if (loadTextPath != null) {\n      log.info(\"Warning: this is now only tested for Chinese Segmenter\");\n      log.info(\"(Sun Dec 23 00:59:39 2007) (pichuan)\");\n      try {\n        crf.loadTextClassifier(loadTextPath, props);\n        // log.info(\"DEBUG: out from crf.loadTextClassifier\");\n      } catch (Exception e) {\n        throw new RuntimeException(\"error loading \" + loadTextPath, e);\n      }\n    } else if (crf.flags.loadJarClassifier != null) {\n      // legacy option support\n      crf.loadClassifierNoExceptions(crf.flags.loadJarClassifier, props);\n    } else if (crf.flags.trainFile != null || crf.flags.trainFileList != null) {\n      Timing timing = new Timing();\n      // temporarily unlimited size of knownLCWords\n      int knownLCWordsLimit = crf.knownLCWords.getMaxSize();\n      crf.knownLCWords.setMaxSize(-1);\n      crf.train();\n      crf.knownLCWords.setMaxSize(knownLCWordsLimit);\n      timing.done(log, \"CRFClassifier training\");\n    } else {\n      crf.loadDefaultClassifier();\n    }\n\n    crf.loadTagIndex();\n","sourceCodeStart":2969,"sourceCodeEnd":3005,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFClassifier.java#L2969-L3005","documentation":"In the classifier-loading option chain, when flags.loadTextClassifier is set the code calls crf.loadTextClassifier(loadTextPath, props); any Exception thrown there is wrapped in RuntimeException('error loading <path>'). It is a generic wrapper indicating the text classifier file could not be parsed or read (including the inner 'format error' / 'weights format error' cases).","triggerScenarios":"Setting -loadTextClassifier (or the properties key) to a path that is missing, unreadable, or not in the expected text format; any IOException or RuntimeException inside loadTextClassifier is rethrown with this message.","commonSituations":"Typo'd or wrong path in loadTextClassifier flag; pointing at a binary .ser.gz model; text file from a different NLP version; permission issues; file truncated in transit.","solutions":["Verify the loadTextClassifier path exists and is readable (ls -l, permissions).","Inspect the chained cause (getCause) — the inner message ('format error', 'weights format error', IO error) tells the real problem.","Confirm the file is a text-format classifier whose first line is 'weights.length=<n>'; use loadClassifier for binary models.","Regenerate the text dump from the serialized model using the matching Stanford NLP version.","Test loading in a small program directly calling loadTextClassifier to isolate the failing flag."],"exampleFix":"// before\njava -cp stanford-segmenter.jar ... -loadTextClassifier model.ser.gz   // wrong kind of file\n// after\njava -cp stanford-segmenter.jar ... -loadClassifier model.ser.gz       // binary model\n// or regenerate: -loadTextClassifier model.txt with a valid text dump","handlingStrategy":"validation","validationCode":"File f = new File(loadTextPath);\nif (!f.isFile() || !f.canRead()) throw new IllegalArgumentException(\"loadTextClassifier path missing/unreadable: \" + loadTextPath);\ntry (BufferedReader br = new BufferedReader(new FileReader(f))) {\n  if (!br.readLine().startsWith(\"weights.length=\"))\n    throw new IllegalArgumentException(\"Not a text-format classifier: \" + loadTextPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  crf.loadTextClassifier(loadTextPath, props);\n} catch (RuntimeException e) {\n  Throwable cause = e.getCause(); // 'format error', 'weights format error', or IOException\n  throw new IOException(\"Failed to load text classifier \" + loadTextPath + \": \" + cause, cause);\n}","preventionTips":["Confirm the file is a text dump, not a binary .ser.gz model.","Check path and permissions before training/loading runs.","Always inspect getCause() for the real failure.","Regenerate text dumps with the same library version."],"tags":["java","io","configuration","file-read"],"backgroundTag":"file-read-failed","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"}