stanfordnlp/CoreNLP · error

Error annotating

Error message

Error annotating 

What it means

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.

Solutions

  1. Read the full exception logged after the colon to identify the real failure
  2. Repair or remove the offending input file and re-run it individually
  3. Increase -Xmx if the per-file error is an OutOfMemoryError
  4. Verify required models are on the classpath for the requested annotators
  5. Keep continueOnAnnotateError so one bad file doesn't kill the batch

Example fix

// before
java StanfordCoreNLP -continueOnAnnotateError -filelist files.txt  // failures silently skipped
// after
// inspect logged cause, e.g. fix encoding, then re-run just the failed file
java StanfordCoreNLP -file /data/corpus/bad.xml -outputDirectory out/
Defensive patterns

Strategy: try-catch

Validate before calling

// validate inputs before batching
for (File f : files) {
    if (f.length() == 0 || !f.canRead()) System.err.println("bad input: " + f);
}

Try / catch

try {
    pipeline.annotate(annotation);
} catch (Exception ex) {
    logger.warn("Error annotating " + file + ": " + ex, ex); // keep cause for diagnosis
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/04ff34fbcb5b8ba7. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java:1383

            synchronized (totalProcessed) {
              totalProcessed.incValue(1);
              if (totalProcessed.intValue() % 1000 == 0) {
                logger.info("Processed " + totalProcessed + " documents");
              }
              // check we've processed or errored on every file, handle tasks to run after last document
              if ((totalProcessed.intValue() + totalErrorAnnotating.intValue()) == files.size()) {
                // clear pool if necessary
                if (clearPool)
                  GLOBAL_ANNOTATOR_CACHE.clear();
                // print out timing info
                if (TIME && pipeline.isPresent() && tim.isPresent())
                  logTimingInfo(pipeline.get(), tim.get());
              }
            }
          } else if (continueOnAnnotateError) {
            // Error annotating but still wanna continue
            // (maybe in the middle of long job and maybe next one will be okay)
            logger.err("Error annotating " + file.getAbsoluteFile() + ": " + ex);
            synchronized (totalErrorAnnotating) {
              totalErrorAnnotating.incValue(1);
              // check we've processed or errored on every file, handle tasks to run after last document
              if ((totalProcessed.intValue() + totalErrorAnnotating.intValue()) == files.size()) {
                // clear pool if necessary
                if (clearPool)
                  GLOBAL_ANNOTATOR_CACHE.clear();
                // print out timing info
                if (TIME && pipeline.isPresent() && tim.isPresent())
                  logTimingInfo(pipeline.get(), tim.get());
              }
            }

          } else {
            // if stopping due to error, make sure to clear the pool
            if (clearPool) {
              GLOBAL_ANNOTATOR_CACHE.clear();
            }

View on GitHub (pinned to 1b7edd19c4)