Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Response parsing error at EnvelopValidation #277

Open
tamasoz opened this issue Jul 18, 2017 · 15 comments
Open

JSON Response parsing error at EnvelopValidation #277

tamasoz opened this issue Jul 18, 2017 · 15 comments
Assignees

Comments

@tamasoz
Copy link

tamasoz commented Jul 18, 2017

I am keep getting errors when harvested results are being reprojected using the preconfigured Geometry-service.

I am using the "http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/" GeometryServer. The GTP log file is full of the following errors:

17-Jul-2017 00:01:52.032 WARNING [harvester] com.esri.gpt.catalog.arcgis.metadata.ServiceInfo$EnvelopeValidator.validateEnvelope Error projecting envelope, problem parsing JSON response, url=http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=2039&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A183476.10500000045%2C%22ymin%22%3A636683.0950000007%2C%22xmax%22%3A191879.34999999963%2C%22ymax%22%3A648499.5600000005%7D%5D%7D
 org.json.JSONException: A JSONObject text must begin with '{' at character 0

If I call the URL from the exception log it is working fine, the JSON response seems correct. The Tomcat Connector is configured for UTF-8 encoding. If I let the harvest to begin with the "Automatically approve newly acquired resources" tab ticked the resource will get registered without re-projection and the envelopes are all around the world - but not at the right locations.

Any help will be very much appreciated!

Tamas

@tamasoz
Copy link
Author

tamasoz commented Jul 18, 2017

Thank you @mhogeweg ! I encountered this issue in both 1.2.7 and 1.2.8 version.

@zguo , @pandzel - do let me know if you need any further information regarding this problem.

Tamas

@tamasoz
Copy link
Author

tamasoz commented Jul 21, 2017

Any news about the solution of the previously mentioned issue? Our server is still going through the usual problem - trying to convert envelop using Geometryservice and getting the same error message over and over again. Every time I check the URL to the geometryservice it is a valid JSON...

@zguo
Copy link
Collaborator

zguo commented Jul 21, 2017

is the service you are trying to harvest available publicly so we can take a look. it would be good to have the url.

also not sure if the geoportal server can access the task url, if you try the task url (http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=2039&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A183476.10500000045%2C%22ymin%22%3A636683.0950000007%2C%22xmax%22%3A191879.34999999963%2C%22ymax%22%3A648499.5600000005%7D%5D%7D) on the server geoportal is running, does it work for you?

@tamasoz
Copy link
Author

tamasoz commented Jul 22, 2017

OK, I prepared some log-file data for you. From the GTP logfile you can see what servers are being harvested - the servers has a wide range of geographic compositions (USA, Japan, PRC, Brazil, Middle-East, etc), so there are a variety of projections in the services.

I also included a text file showing the URL of registered service layer and the printout of the layer metadata from geoportal - you can see that service layers from US and Canada ended up in Africa. Also, there are two dataset from a Russian server from where services of similar locations were either registered correctly or ended up in Singapore.

Lastly I deployed a test servlet on the hosting Tomcat, connecting to the geometry service on the task.arcgisonline.com (the one you sent over previously). response received fine, first character is indeed a {.

This is a link for a public onedrive folder containing all infromation you may need (logfile, metadata prinotus, screenshot of sucessful servlet connection).

https://1drv.ms/f/s!Alm4fNYZo5C0gcR1I4km9S9PTOIwgA

gpt.2017-07-21.zip
GEOPORTAL_ERROR_EXPLANATIONS.txt
testing_connection

But it looks like i managed to upload these files here...

Let me know if you need any further details...

Tamas

@zguo
Copy link
Collaborator

zguo commented Jul 25, 2017

I tried quite a few ags sites from the log file, unfortunately I was unable to reproduce the issue you are having, also for those in GEOPORTAL_ERROR_EXPLANATIONS.txt, the coordinate I got back is different from yours. e.g. on the first one titled "PLSS Boundaries_9K" I got the following back:

ows:WGS84BoundingBox
ows:LowerCorner-81.56591253766693 27.031551149494298</ows:LowerCorner>
ows:UpperCorner-80.92742719389345 27.647822208496503</ows:UpperCorner>
</ows:WGS84BoundingBox>

I wonder if it is related to system environment/network configuration, do you have more info such as system environment, version of geoportal? customizations, etc. also you might try tools such as fiddler to check the network communication to see if the requests/response looks correct

it's also possible to add some log statement to ServiceInfo.java after line 638 (String response = http.readResponseAsCharacters();) to log the url and response

LOGGER.finest(String.format("%s => %s", projectionUrl, response));

@tamasoz
Copy link
Author

tamasoz commented Jul 25, 2017

@zguo I cannot check the PLSS Boundaries_9K response anymore as this dataset is not available publicly anymore - we just used this for test anyway. But the response you got back is right anyway - the one I included in the GEOPORTAL_ERROR_EXPLANATIONS.txt is completely wrong.

The system is composed as follows:
Azure Linux VM - Ubuntu 16.04 LTS, Tomcat Apache Tomcat/8.5.15 configured with self signed SSL certificate, both http and https running on the default Tomcat ports, UTF-8 encoding. Oracle JDK 8 installed (can't check the exact version now, but should be towards the latest ones), network configuration follows standard Azure VM network configuration, standard network interface, network security group, etc. Geoportal 1.2.8. (and previously 1.2.7) behaved on the same way on a different hosting provider infrastructure (still on Ubuntu 16.04). Geoportal running on very standard configuration, basic authentication (no LDAP), no additional features installed yet (like the Solr indexer). In overall the system is sort of stable, we tried out many different Arcgis servers to harvest from - majority were working fine with the exception of this envelope issue.

I will add the logger line to the deployed webapp's code as soon as I get the chance and I will let you know what was recorded.

@tamasoz
Copy link
Author

tamasoz commented Aug 1, 2017

Finally I got some time to rebuild geoportal from source along with the new line for Logger (should this line be left in for the next release perhaps?) and after a few failed builds I managed to have the new WAR file deployed on the server.

The result is simple - when there is a failure of parsing the JSON response is purely because the JSONparser/JSONObject receives a completely empty string!

As the logging was set to FINEST I save the hassle of posting the whole log file - which went up for several hundred megabytes pretty quickly, so the extracts are as follows:

FINEST [harvester] com.esri.gpt.catalog.arcgis.metadata.ServiceInfo$EnvelopeValidator.validateEnvelope http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=102698&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A2960377.7691159137%2C%22ymin%22%3A179616.72617781907%2C%22xmax%22%3A2983442.4359129965%2C%22ymax%22%3A195029.18386990577%7D%5D%7D =>

01-Aug-2017 03:42:35.772 WARNING [harvester] com.esri.gpt.catalog.arcgis.metadata.ServiceInfo$EnvelopeValidator.validateEnvelope Error projecting envelope, problem parsing JSON response, url=http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=102698&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A2960377.7691159137%2C%22ymin%22%3A179616.72617781907%2C%22xmax%22%3A2983442.4359129965%2C%22ymax%22%3A195029.18386990577%7D%5D%7D org.json.JSONException: A JSONObject text must begin with '{' at character 0

...and another one...

{"geometries":[{"xmin":-71.29006099999998,"ymin":-53.783882999999946,"xmax":-57.550354999999975,"ymax":-24.790544999999952}]} 01-Aug-2017 03:43:15.577 FINEST [harvester] com.esri.gpt.catalog.arcgis.metadata.ServiceInfo$EnvelopeValidator.validateEnvelope http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=102100&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A-7935973.289141409%2C%22ymin%22%3A-7129332.105468956%2C%22xmax%22%3A-6406476.213572122%2C%22ymax%22%3A-2850039.6428465564%7D%5D%7D =>

01-Aug-2017 03:43:15.577 WARNING [harvester] com.esri.gpt.catalog.arcgis.metadata.ServiceInfo$EnvelopeValidator.validateEnvelope Error projecting envelope, problem parsing JSON response, url=http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=102100&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A-7935973.289141409%2C%22ymin%22%3A-7129332.105468956%2C%22xmax%22%3A-6406476.213572122%2C%22ymax%22%3A-2850039.6428465564%7D%5D%7D org.json.JSONException: A JSONObject text must begin with '{' at character 0

...and one more...

{"geometries":[{"xmin":-90.168001397791386,"ymin":38.567268640704214,"xmax":-89.961585463235281,"ymax":38.625623223574806}]} 01-Aug-2017 03:43:33.968 FINEST [harvester] com.esri.gpt.catalog.arcgis.metadata.ServiceInfo$EnvelopeValidator.validateEnvelope http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=102672&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A2296203.790757995%2C%22ymin%22%3A692102.0610857382%2C%22xmax%22%3A2355173.1865984946%2C%22ymax%22%3A713288.1168106571%7D%5D%7D =>

01-Aug-2017 03:43:33.968 WARNING [harvester] com.esri.gpt.catalog.arcgis.metadata.ServiceInfo$EnvelopeValidator.validateEnvelope Error projecting envelope, problem parsing JSON response, url=http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=102672&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A2296203.790757995%2C%22ymin%22%3A692102.0610857382%2C%22xmax%22%3A2355173.1865984946%2C%22ymax%22%3A713288.1168106571%7D%5D%7D org.json.JSONException: A JSONObject text must begin with '{' at character 0

Just to be on the safe side we deployed the similar architecture on a Windows VM - same issues were occurring. Recorded a Network Monitor session too, but that wasn't too informative - I can provided that too if you need it - just let me know.

To be honest I am out of ideas what could be the issue here - I assume the tasks.arcgisonline.com is not being throttled. We do not currently have ArcGIS server licence, only ArcGIS Online access, hence we are forced to use tasks.arcgisonline.com for Geometry services.

Well, this is pretty much it. Thanks.

Tamas

@tamasoz
Copy link
Author

tamasoz commented Aug 1, 2017

...not all envelop validation failed, these ones were ok:
01-Aug-2017 03:42:20.676 FINEST [harvester] com.esri.gpt.catalog.arcgis.metadata.ServiceInfo$EnvelopeValidator.validateEnvelope http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=102698&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A2941023.469569996%2C%22ymin%22%3A153422.35107323527%2C%22xmax%22%3A2987305.6598138288%2C%22ymax%22%3A200116.12153065205%7D%5D%7D => {"geometries":[{"xmin":-93.981201811189862,"ymin":36.586197994695965,"xmax":-93.822444699376021,"ymax":36.715242824185808}]}

...and this one was fine too...

FINEST [harvester] com.esri.gpt.catalog.arcgis.metadata.ServiceInfo$EnvelopeValidator.validateEnvelope http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&inSR=28355&outSR=4326&geometries=%7B%22geometryType%22%3A%22esriGeometryEnvelope%22%2C%22geometries%22%3A%5B%7B%22xmin%22%3A229615.524%2C%22ymin%22%3A5167740.9343%2C%22xmax%22%3A613826.026%2C%22ymax%22%3A5613382.125%7D%5D%7D => {"geometries":[{"xmin":143.650374778556,"ymin":-43.643325812988458,"xmax":148.41109744616682,"ymax":-39.586652272015336}]}

@zguo
Copy link
Collaborator

zguo commented Aug 1, 2017

The log is helpful, we thought might be either the request url or the response.
if you try to harvest the same site multiple times, maybe you can check if it works this time and then the same not working the second time for the same envelope?

@tamasoz
Copy link
Author

tamasoz commented Aug 1, 2017

@zguo well, that is also possible though if we need the printout from the JSON responses as above then I need to redeploy the server again, which takes a bit of a time and I am pretty short on that these days.

However, in the meantime I can prepare a list summarising what where those services where the envelop validation failed and what are those where it went through fine. I can also find an arcgis server's services in the current repository where services already failed the envelop validation and try to re-harvest it again - see what will happen. Though I must note that I think these services are re-harvested every fortnight and I did see in the logfile that envelop validation keeps failing, so probably they will fail again - but will confirm that later on.

@zguo
Copy link
Collaborator

zguo commented Aug 2, 2017

I tried to load test a few of your requests (each ~100 times concurrently), I got a few of failed results even though most time is a success for the same request, thus wondering if it is something related to the load to the geometry service. for the harvesting test, I think one quick way it is to find a site that is having the issue from the existing log, then try re-harvesting for that site a few times more to see if the same issue happens again with exactly same request.

@tamasoz
Copy link
Author

tamasoz commented Aug 2, 2017

@zguo Ok, I will try to do that later on today or so.

Yes, it seems that this issue is related to the service rather the geoportal itself (but let us confirm that with the agreed checks) - but then it might be a good idea to build in some sort of defensive mechanism in the next release, for example upon failed envelop-validation the system should log the type of HTTP error code it receives (if any as ArcGIS tend to send empty HTTP 200 when error occurs) then the thread should get delayed a second or something and re-try it again for a few times before moving on to the next resource in the queue...the number of re-tries could be perhaps configured from gpt.xml - or switched it off completely. At the end of the day with the advent of cloud systems more and more users relies solely on ArcGIS online, meaning that they will not have access to an in-house ArcGIS server instance for geometry-service. Again - if this issue is related to the service...

@tamasoz
Copy link
Author

tamasoz commented Aug 2, 2017

I can also try to point the geometry service to another location temporarily - see what the results become then...

@tamasoz
Copy link
Author

tamasoz commented Aug 6, 2017

@zguo Well, I managed to break our Lucene index, so I had to start rebuilding the whole system (I could not get the index rebuilt properly for some reason) and I think I found the core of the problem. It seems that we were trying to index a large number of resources simultaneously and this might have kept triggering a security countermeasure of the ArcGIS Online geometry service. Since I started repopulating the server I have been adding services to be harvested one-by-one then starting a manual synchronization rather in batches with periodic synch - so far we have not received any empty JSON response from the geometry service.

I already managed to add 14 services and harvest them successfully - had no issues whatsoever. I think the real problem for us can happen again when geoportal will start re-harvesting large set of resources on a periodic basis - but I think that can be managed by spreading them out evenly throughout a given time period.

Anyway, if I see this issue happening again I will do a more detailed investigations regarding ArcGIS Online geometry service availability - but at this stage it seems we are fine, thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants