{"record":{"id":"04ff34fbcb5b8ba7","repo":"stanfordnlp/CoreNLP","slug":"error-annotating","errorCode":null,"errorMessage":"Error annotating ","messagePattern":"Error annotating ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java","lineNumber":1383,"sourceCode":"            synchronized (totalProcessed) {\n              totalProcessed.incValue(1);\n              if (totalProcessed.intValue() % 1000 == 0) {\n                logger.info(\"Processed \" + totalProcessed + \" documents\");\n              }\n              // check we've processed or errored on every file, handle tasks to run after last document\n              if ((totalProcessed.intValue() + totalErrorAnnotating.intValue()) == files.size()) {\n                // clear pool if necessary\n                if (clearPool)\n                  GLOBAL_ANNOTATOR_CACHE.clear();\n                // print out timing info\n                if (TIME && pipeline.isPresent() && tim.isPresent())\n                  logTimingInfo(pipeline.get(), tim.get());\n              }\n            }\n          } else if (continueOnAnnotateError) {\n            // Error annotating but still wanna continue\n            // (maybe in the middle of long job and maybe next one will be okay)\n            logger.err(\"Error annotating \" + file.getAbsoluteFile() + \": \" + ex);\n            synchronized (totalErrorAnnotating) {\n              totalErrorAnnotating.incValue(1);\n              // check we've processed or errored on every file, handle tasks to run after last document\n              if ((totalProcessed.intValue() + totalErrorAnnotating.intValue()) == files.size()) {\n                // clear pool if necessary\n                if (clearPool)\n                  GLOBAL_ANNOTATOR_CACHE.clear();\n                // print out timing info\n                if (TIME && pipeline.isPresent() && tim.isPresent())\n                  logTimingInfo(pipeline.get(), tim.get());\n              }\n            }\n\n          } else {\n            // if stopping due to error, make sure to clear the pool\n            if (clearPool) {\n              GLOBAL_ANNOTATOR_CACHE.clear();\n            }","sourceCodeStart":1365,"sourceCodeEnd":1401,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java#L1365-L1401","documentation":"When an exception is thrown while annotating a file in batch mode and 'continueOnAnnotateError' is enabled, StanfordCoreNLP logs 'Error annotating <file>: <exception>' instead of aborting, increments totalErrorAnnotating, and proceeds to the next file. The root cause is in the attached exception, not this message.","triggerScenarios":"Running StanfordCoreNLP with -continueOnAnnotateError over a filelist when one document fails annotation (e.g. malformed text, tokenizer/model error, OOM on one file); exception caught in the annotateCallable for that file.","commonSituations":"Batch-corrupting inputs like binary files or wrong-encoding text in a large corpus; one huge file causing OOM mid-job; missing model files affecting certain annotator requests.","solutions":["Read the full exception logged after the colon to identify the real failure","Repair or remove the offending input file and re-run it individually","Increase -Xmx if the per-file error is an OutOfMemoryError","Verify required models are on the classpath for the requested annotators","Keep continueOnAnnotateError so one bad file doesn't kill the batch"],"exampleFix":"// before\njava StanfordCoreNLP -continueOnAnnotateError -filelist files.txt  // failures silently skipped\n// after\n// inspect logged cause, e.g. fix encoding, then re-run just the failed file\njava StanfordCoreNLP -file /data/corpus/bad.xml -outputDirectory out/","handlingStrategy":"try-catch","validationCode":"// validate inputs before batching\nfor (File f : files) {\n    if (f.length() == 0 || !f.canRead()) System.err.println(\"bad input: \" + f);\n}","typeGuard":null,"tryCatchPattern":"try {\n    pipeline.annotate(annotation);\n} catch (Exception ex) {\n    logger.warn(\"Error annotating \" + file + \": \" + ex, ex); // keep cause for diagnosis\n}","preventionTips":["Use continueOnAnnotateError for large batches and collect the failed list for reprocessing","Allocate ample heap and ensure all models are on the classpath","Sanitize/validate corpus files (encoding, format) before batching"],"tags":["batch","annotation-failure","pipeline"],"backgroundTag":"http-error-response","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}