stanfordnlp/CoreNLP · error · javax.servlet.ServletException

Invalid outputFormat setting.

Error message

Invalid outputFormat setting.

What it means

Servlet initialization failure in NERServlet.init: the servlet-config init parameter outputFormat is missing or blank, so the servlet cannot determine how to render NER results and aborts startup with a ServletException.

Solutions

  1. Add <init-param><param-name>outputFormat</param-name><param-value>xml</param-value></init-param> to the servlet config in web.xml
  2. Use a non-empty value such as xml, json, or tabbed as appropriate for the deployment
  3. Redeploy the WAR after fixing web.xml so init() re-runs with the parameter
  4. Verify with container logs / getInitParameter name spelling (case-sensitive).

Example fix

<!-- before -->
<servlet><servlet-name>NER</servlet-name><servlet-class>...NERServlet</servlet-class></servlet>
<!-- after -->
<servlet><servlet-name>NER</servlet-name><servlet-class>...NERServlet</servlet-class>
  <init-param><param-name>outputFormat</param-name><param-value>xml</param-value></init-param>
</servlet>
Defensive patterns

Strategy: validation

Validate before calling

String fmt = getServletConfig().getInitParameter("outputFormat");
if (fmt == null || fmt.trim().isEmpty()) throw new ServletException("outputFormat init-param required");

Try / catch

try { servlet.init(cfg); } catch (ServletException e) { log.severe("Servlet misconfigured: " + e.getMessage()); }

Prevention

When it happens

Trigger: Deploying the webapp without an <init-param> named outputFormat in web.xml (or annotation equivalent), or declaring it with only whitespace.

Common situations: Hand-edited web.xml that dropped the parameter; renaming the parameter while the servlet expects the exact name; container deployments that strip empty init-params.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/ie/ner/webapp/NERServlet.java:45

 **/

public class NERServlet extends HttpServlet {

  private static final long serialVersionUID = 1584102147050497227L;

  private String format;
  private boolean spacing;
  private String defaultClassifier;
  private List<String> classifiers = new ArrayList<>();
  private Map<String, CRFClassifier<CoreMap>> ners;

  private static final int MAXIMUM_QUERY_LENGTH = 3000;

  @Override
  public void init() throws ServletException {
    format = getServletConfig().getInitParameter("outputFormat");
    if (format == null || format.trim().isEmpty()) {
      throw new ServletException("Invalid outputFormat setting.");
    }

    String spacingStr = getServletConfig().getInitParameter("preserveSpacing");
    if (spacingStr == null || spacingStr.trim().isEmpty()) {
      throw new ServletException("Invalid preserveSpacing setting.");
    }
    //spacing = Boolean.valueOf(spacingStr).booleanValue();
    spacingStr = spacingStr.trim().toLowerCase();
    spacing = "true".equals(spacingStr);

    String path = getServletContext().getRealPath("/WEB-INF/data/models");
    for (String classifier : new File(path).list()) {
      classifiers.add(classifier);
    }
    // TODO: get this from somewhere more interesting?
    defaultClassifier = classifiers.get(0);

    for (String classifier : classifiers) {

View on GitHub (pinned to 1b7edd19c4)