stanfordnlp/CoreNLP · error · IllegalStateException

Haven't implemented protocol

Error message

Haven't implemented protocol: ${backend.protocol}

What it means

StanfordCoreNLPClient connects to a CoreNLP server via a URLConnection. doAnnotation only implements http/https protocols; any other scheme in the backend server URL reaches the default branch and throws IllegalStateException 'Haven't implemented protocol'.

Solutions

  1. Set the server URL to a proper http://host:port or https://host:endpoint address.
  2. Fix URL typos so java.net.URL parses scheme as http/https.
  3. Run the CoreNLP server locally (java -mx4g -cp '*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000) and point the client at http://localhost:9000.
  4. If a non-HTTP transport is needed, extend doAnnotation to handle that protocol - it is not supported out of the box.

Example fix

// before
Properties props = new Properties();
props.setProperty("corenlp.server", "localhost:9000"); // parsed protocol invalid
// after
props.setProperty("corenlp.server", "http://localhost:9000");
Defensive patterns

Strategy: validation

Validate before calling

URI uri = URI.create(serverUrl);
if (!"http".equals(uri.getScheme()) && !"https".equals(uri.getScheme())) {
  throw new IllegalArgumentException("CoreNLP server URL must use http/https: " + serverUrl);
}

Try / catch

try { client.annotate(annotation); } catch (IllegalStateException e) { if (e.getMessage().startsWith("Haven't implemented protocol")) { log.error("Use http(s) server URL, got: {}", e.getMessage()); } throw e; }

Prevention

When it happens

Trigger: Constructing a StanfordCoreNLPClient (or CoreNLPHttpClient) whose server URL uses a scheme other than http/https, e.g. 'file:', 'ftp:', or a malformed URL where the parsed protocol is empty/unexpected.

Common situations: Typo in server URL ('htp://', missing scheme); pointing the client at a unix-socket/file path; config copied from another tool using a different scheme.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/StanfordCoreNLPClient.java:519

        }
        // 1.2 Set some protocol-independent properties
        connection.setDoOutput(true);
        connection.setRequestProperty("Content-Type", "application/x-protobuf");
        connection.setRequestProperty("Content-Length", Integer.toString(message.length));
        connection.setRequestProperty("Accept-Charset", "utf-8");
        connection.setRequestProperty("User-Agent", StanfordCoreNLPClient.class.getName());
        if (timeoutMilliseconds > 0) {
          connection.setConnectTimeout(timeoutMilliseconds);
          connection.setReadTimeout(timeoutMilliseconds);
        }
        // 1.3 Set some protocol-dependent properties
        switch (backend.protocol) {
          case "https":
          case "http":
            ((HttpURLConnection) connection).setRequestMethod("POST");
            break;
          default:
            throw new IllegalStateException("Haven't implemented protocol: " + backend.protocol);
        }

        // 2. Annotate
        // 2.1. Fire off the request
        connection.connect();
        connection.getOutputStream().write(message);
        connection.getOutputStream().flush();
        // 2.2 Await a response
        // -- It might be possible to send more than one message, but we are not going to do that.
        Annotation response = serializer.read(connection.getInputStream()).first;
        // 2.3. Copy response over to original annotation
        for (Class key : response.keySet()) {
          annotation.set(key, response.get(key));
        }

        //Succeeded!  Can break out of the loop now
        return;
      } catch (Throwable t) {

View on GitHub (pinned to 1b7edd19c4)