Getting 403 return code when initializing SchemaVersion class
odieduck opened this issue · 3 comments
Stacktrace:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.github.fge.jsonschema.SchemaVersion.(SchemaVersion.java:66)
at com.github.fge.jsonschema.SchemaVersion.(SchemaVersion.java:45)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://json-schema.org/draft-04/schema#
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1627)
at java.net.URL.openStream(URL.java:1041)
at com.github.fge.jackson.JsonLoader.fromURL(JsonLoader.java:117)
at com.github.fge.jsonschema.SchemaVersion.(SchemaVersion.java:64)
It seems sometimes the HTTP request to get the JSON schema will fail due to firewall settings.
If we change the code to this we can avoid this issue:
location = URI.create(uri);
URL url = new URL(uri);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.addRequestProperty("User-Agent","Test");
schema = JsonLoader.fromReader(new InputStreamReader(conn.getInputStream()));
Hi @odieduck
The current version in master appears to be loading from the resource in the classpath.
Is this still an issue?
Any information on this ? i seem to be getting the same issue.
It's no longer a issue for us. We overwrite this class and load the scheme from class path. It's painful for us to upgrade dependency versions.
The new version has changed this, therefore, I'm ok to close this issue.
Thanks for looking into it!