{"record":{"id":"04b912d46d5afa7b","repo":"stanfordnlp/CoreNLP","slug":"not-an-http-uri","errorCode":null,"errorMessage":"Not an HTTP URI","messagePattern":"Not an HTTP URI","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/pipeline/WebServiceAnnotator.java","lineNumber":203,"sourceCode":"   *\n   * @param uri The URL we are trying to ping.\n   *\n   * @return True if we got any non-5XX response from the endpoint.\n   */\n  protected boolean ping(String uri) {\n    try {\n      URL url = new URL(uri);\n      HttpURLConnection connection = (HttpURLConnection) url.openConnection();\n      connection.setRequestProperty(\"Accept-Charset\", \"UTF-8\");\n      connection.setRequestMethod(\"GET\");\n      connection.connect();\n      int code = connection.getResponseCode();\n      return code < 500 || code >= 600;\n    } catch (MalformedURLException e) {\n      log.warn(\"Could not parse URL: \" + uri);\n      return false;\n    } catch (ClassCastException e) {\n      log.warn(\"Not an HTTP URI\");\n      return false;\n    } catch (IOException e) {\n      return false;\n    }\n\n  }\n\n\n  /**\n   * Start the actual server.\n   *\n   * @param command the command we are using to start the sever.\n   *\n   * @return True if the server was started; false otherwise.\n   */\n  private boolean startServer(String[] command) {\n    ProcessBuilder proc = new ProcessBuilder(command);\n    try {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/WebServiceAnnotator.java#L185-L221","documentation":"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.","triggerScenarios":"Calling ready() or annotateImpl() with a `uri` using a non-HTTP scheme (file:, jar:, ftp:) so connection casting to HttpURLConnection fails.","commonSituations":"Pointing the annotator at a file:// or unix-socket style endpoint; typos in scheme; assuming any URL works when only HTTP servers are supported.","solutions":["Change the uri to use http:// (or https://) scheme.","Verify the target is an actual HTTP web service, not a local file or socket.","Check that no proxy/custom URLStreamHandler is producing a non-HttpURLConnection.","Validate the scheme in configuration before instantiating the annotator."],"exampleFix":"// before\nprops.setProperty(\"webservice.uri\", \"file:///tmp/server.sock\");\n// after\nprops.setProperty(\"webservice.uri\", \"http://localhost:8080\");","handlingStrategy":"validation","validationCode":"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);","typeGuard":null,"tryCatchPattern":"if (!annotator.ready()) { log.warn(\"Non-HTTP endpoint: \" + uri); throw new IllegalStateException(\"WebServiceAnnotator requires an http(s) URI\"); }","preventionTips":["Restrict configuration to http/https schemes","Never point the annotator at file: or socket URIs","Check annotator.ready() before annotating"],"tags":["network","url","configuration"],"backgroundTag":"invalid-url","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}