stanfordnlp/CoreNLP · error · IllegalArgumentException
Cannot output in format
Error message
Cannot output in format ${outputFormat} from the interactive shell What it means
In StanfordCoreNLPClient's interactive shell, the chosen output format has no implemented printing path for the annotation. Only text/json/xml/html/serialized cases exist; anything else (or SERVLET-style formats) falls to default and throws IllegalArgumentException. The shell cannot honor the requested output format.
Solutions
- Set -outputFormat to one the shell supports: text, json, xml, or html
- Check the source of StanfordCoreNLPClient (shell loop) for the exact supported case labels in your version
- If you need serialized output, write results programmatically via the client API instead of the interactive shell
Example fix
// before java -cp corenlp.jar edu.stanford.nlp.pipeline.StanfordCoreNLPClient -outputFormat conll -annotators tokenize // after java -cp corenlp.jar edu.stanford.nlp.pipeline.StanfordCoreNLPClient -outputFormat json -annotators tokenize
Defensive patterns
Strategy: validation
Validate before calling
Set<String> supported = Set.of("text","json","xml","html");
String fmt = props.getProperty("outputFormat", "json");
if (!supported.contains(fmt)) throw new IllegalArgumentException("Shell supports only: " + supported + ", got: " + fmt); Try / catch
try {
client.runShell(props);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("from the interactive shell")) {
props.setProperty("outputFormat", "text");
client.runShell(props);
} else throw e;
} Prevention
- Keep outputFormat within text/json/xml/html when using the interactive shell
- Validate CLI flags against the client's supported set at startup
When it happens
Trigger: Calling StanfordCoreNLPClient.run() with the interactive shell active while the -outputFormat property is set to a value the shell switch does not handle (e.g. 'json' omitted by build, or an arbitrary string like 'conll').
Common situations: Users passing server-style output formats (e.g. 'serialized', custom formats) to the client shell; typo'd outputFormat values; copy-pasting CLI options between StanfordCoreNLP and StanfordCoreNLPClient.
Related errors
- Format is not implemented: " + FORMAT
- Sorry, but dependencies cannot be output as part of the…
- args: treebankPath trainNums testNums
- Bad character encoding
- Bad serialized file:
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/aa260284868d4a94.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/pipeline/StanfordCoreNLPClient.java:618
new XMLOutputter().print(anno, System.out);
break;
case JSON:
new JSONOutputter().print(anno, System.out);
System.out.println();
break;
case CONLL:
new CoNLLOutputter().print(anno, System.out);
System.out.println();
break;
case TEXT:
new TextOutputter().print(anno, System.out);
break;
case SERIALIZED:
warn("You probably cannot read the serialized output, so printing in text instead");
new TextOutputter().print(anno, System.out);
break;
default:
throw new IllegalArgumentException("Cannot output in format " + outputFormat + " from the interactive shell");
}
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
});
}
/**
* The implementation of what to run on a command-line call of CoreNLPWebClient
*
* @throws IOException If any IO problem
*/
public void run() throws IOException {
StanfordRedwoodConfiguration.minimalSetup();
StanfordCoreNLP.OutputFormat outputFormat = StanfordCoreNLP.OutputFormat.valueOf(properties.getProperty("outputFormat", "text").toUpperCase(Locale.ROOT));
//View on GitHub (pinned to 1b7edd19c4)