stanfordnlp/CoreNLP · warning
Could not parse URL
Error message
Could not parse URL: ${uri} What it means
WebServiceAnnotator.ping() validates that the configured server URI is reachable before annotating. When the URI string is malformed (cannot be converted to a URL), a MalformedURLException is caught and a warning is logged, and ping returns false so the annotator reports itself not ready.
Solutions
- Fix the `uri` property to a fully qualified absolute URL, e.g. http://host:port.
- Start the web service server and confirm the endpoint exists before running the pipeline.
- Log/print the configured URI value to spot typos or unresolved property substitution.
- If the URI comes from properties/environment, validate it with new URI(...) or URL parsing before constructing the annotator.
Example fix
// before
props.setProperty("webservice.uri", "localhost:9000");
// after
props.setProperty("webservice.uri", "http://localhost:9000"); Defensive patterns
Strategy: validation
Validate before calling
try { new java.net.URL(uri); if (!uri.startsWith("http")) throw new IllegalArgumentException("uri must be http(s)"); } catch (java.net.MalformedURLException e) { throw new IllegalArgumentException("Bad service uri: " + uri); } Try / catch
if (!annotator.ready()) { log.warn("Service unreachable or bad URI: " + uri); return fallbackAnnotate(input); } Prevention
- Always use fully qualified http(s):// URLs in annotator properties
- Ping the service endpoint before running the full pipeline
- Externalize the URI to one validated config location
When it happens
Trigger: Calling ready() or annotateImpl() when the `uri` option (e.g. serverUrl) is not a parseable absolute URL, such as a missing scheme ("localhost:9000"), illegal characters, or empty string.
Common situations: Setting webservice annotator properties with a typo in the URL, forgetting http:// prefix, using a relative path, or environment-specific config pointing at an unparseable endpoint.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- Not an HTTP URI
- Invalid subnet
- java.net.MalformedURLException
- Could not parse subnet
- Unknown LogPriorType:
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/77604098245ebb0f.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/pipeline/WebServiceAnnotator.java:200
/**
* A utility to ping an endpoint. Useful for {@link #live()} and {@link #ready(boolean initialTest)}.
*
* @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.
*/View on GitHub (pinned to 1b7edd19c4)