stanfordnlp/CoreNLP · warning

Not an HTTP URI

Error message

Not an HTTP URI

What it means

WebServiceAnnotator.ping() expects the configured URI to be an HTTP(S) URI. When the URI is a valid URL but not castable to an HttpURLConnection (e.g. file:, https vs unexpected protocol handler, or a URI object that is not http/https), a ClassCastException is caught, the warning is logged, and ping returns false, marking the annotator not ready.

Solutions

  1. Change the uri to use http:// (or https://) scheme.
  2. Verify the target is an actual HTTP web service, not a local file or socket.
  3. Check that no proxy/custom URLStreamHandler is producing a non-HttpURLConnection.
  4. Validate the scheme in configuration before instantiating the annotator.

Example fix

// before
props.setProperty("webservice.uri", "file:///tmp/server.sock");
// after
props.setProperty("webservice.uri", "http://localhost:8080");
Defensive patterns

Strategy: validation

Validate before calling

java.net.URI u = java.net.URI.create(uri); if (!("http".equals(u.getScheme()) || "https".equals(u.getScheme()))) throw new IllegalArgumentException("URI must be http/https: " + uri);

Try / catch

if (!annotator.ready()) { log.warn("Non-HTTP endpoint: " + uri); throw new IllegalStateException("WebServiceAnnotator requires an http(s) URI"); }

Prevention

When it happens

Trigger: Calling ready() or annotateImpl() with a `uri` using a non-HTTP scheme (file:, jar:, ftp:) so connection casting to HttpURLConnection fails.

Common situations: Pointing the annotator at a file:// or unix-socket style endpoint; typos in scheme; assuming any URL works when only HTTP servers are supported.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/WebServiceAnnotator.java:203

   *
   * @param uri The URL we are trying to ping.
   *
   * @return True if we got any non-5XX response from the endpoint.
   */
  protected boolean ping(String uri) {
    try {
      URL url = new URL(uri);
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.setRequestProperty("Accept-Charset", "UTF-8");
      connection.setRequestMethod("GET");
      connection.connect();
      int code = connection.getResponseCode();
      return code < 500 || code >= 600;
    } catch (MalformedURLException e) {
      log.warn("Could not parse URL: " + uri);
      return false;
    } catch (ClassCastException e) {
      log.warn("Not an HTTP URI");
      return false;
    } catch (IOException e) {
      return false;
    }

  }


  /**
   * Start the actual server.
   *
   * @param command the command we are using to start the sever.
   *
   * @return True if the server was started; false otherwise.
   */
  private boolean startServer(String[] command) {
    ProcessBuilder proc = new ProcessBuilder(command);
    try {

View on GitHub (pinned to 1b7edd19c4)