{"record":{"id":"8d5b542740db6177","repo":"stanfordnlp/CoreNLP","slug":"could-not-pre-load-annotators-in-server-encounter","errorCode":null,"errorMessage":"Could not pre-load annotators in server; encountered exception:","messagePattern":"Could not pre-load annotators in server; encountered exception:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java","lineNumber":1882,"sourceCode":"      homepage = new FileHandler(\"edu/stanford/nlp/pipeline/demo/corenlp-brat.html\");\n    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    }\n\n    // Pre-load the models\n    if (StanfordCoreNLPServer.preloadedAnnotators != null) {\n      Properties props = new Properties();\n      server.defaultProps.forEach((key1, value) -> props.setProperty(key1.toString(), value.toString()));\n      // -preload flag alone means to load all default annotators\n      // -preload flag with a list of annotators means to preload just that list (e.g. tokenize,ssplit,pos)\n      String annotatorsToLoad = (StanfordCoreNLPServer.preloadedAnnotators.trim().equals(\"true\")) ?\n          server.defaultProps.getProperty(\"annotators\") : StanfordCoreNLPServer.preloadedAnnotators;\n      if (annotatorsToLoad != null)\n        props.setProperty(\"annotators\", annotatorsToLoad);\n      try {\n        new StanfordCoreNLP(props);\n      } catch (Throwable throwable) {\n        err(\"Could not pre-load annotators in server; encountered exception:\");\n        err(throwable);\n      }\n    }\n\n    // Credentials\n    Optional<Pair<String, String>> credentials = Optional.empty();\n    if (server.username != null && server.password != null) {\n      credentials = Optional.of(Pair.makePair(server.username, server.password));\n    }\n\n    // Run the server\n    log(\"Starting server...\");\n    server.run(credentials, req -> true, res -> {}, homepage, server.ssl, live);\n\n    return server;\n  } // end launchServer\n\n","sourceCodeStart":1864,"sourceCodeEnd":1900,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java#L1864-L1900","documentation":"At server startup, StanfordCoreNLPServer optionally constructs a StanfordCoreNLP pipeline to pre-load the annotators listed by -preloadedAnnotators (or the server default properties) so the first request is fast. If that construction throws any Throwable, the server logs this message plus the throwable and continues starting WITHOUT pre-loaded annotators, so the first real request will pay the model-loading cost or fail.","triggerScenarios":"Starting the server with -preloadedAnnotators naming annotators whose models are missing/corrupt, an invalid annotator name in server.defaultProps' annotators key, or any exception (including OOM) during pipeline construction in the constructor's preload block.","commonSituations":"Typo in the annotators list (e.g. 'depparsee'); models jar not on classpath; specifying an annotator requiring another annotator (e.g. ner without tokenize/ssplit/pos); insufficient -mx heap causing OutOfMemoryError during preload.","solutions":["Read the subsequent logged throwable to identify the root cause (missing model, unknown annotator, OOM).","Correct the -preloadedAnnotators list: valid names, in dependency order (e.g. tokenize,ssplit,pos,lemma,ner).","Ensure the models jar is on the classpath so every preloaded annotator's model files resolve.","Increase heap (-mx8g) if the throwable is OutOfMemoryError; preload fewer annotators otherwise."],"exampleFix":"// before\njava -mx4g -cp corenlp.jar:models.jar StanfordCoreNLPServer -preloadedAnnotators tokenize,ssplit,pos,ner\n// after (ner needs tokenize,ssplit,pos anyway; fix typo / ordering)\njava -mx8g -cp corenlp.jar:models.jar StanfordCoreNLPServer -preloadedAnnotators tokenize,ssplit,pos,lemma,ner","handlingStrategy":"validation","validationCode":"Set<String> valid = Set.of(\"tokenize\",\"ssplit\",\"pos\",\"lemma\",\"ner\",\"parse\",\"depparse\",\"sentiment\",\"coref\");\nfor (String a : preloadList.split(\",\")) {\n    if (!valid.contains(a.trim())) throw new IllegalArgumentException(\"Unknown annotator: \" + a);\n}\nif (Runtime.getRuntime().maxMemory() < 4L*1024*1024*1024) warn(\"Low heap for preloading\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Construct the same pipeline locally once before server deployment to validate preload settings.","Keep annotator names and dependency order reviewed.","Allocate generous heap (-mx8g) for preload-heavy configs."],"tags":["java","server","startup","annotators","class-loading"],"backgroundTag":"module-init-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"}