geosolutions-it / geoserver

Official GeoServer repository
http://geoserver.org
Other
10 stars 7 forks source link

WFS 2.0.0 Parsing Error in PullParserFeatureReader #201

Open imranrajjad opened 3 years ago

imranrajjad commented 3 years ago

While responding/investigation to the ticket , it has been observed that the GetFeature response on layer from WFS 2.x WFS-NG store served from another GeoServer is failing parsing with below error.

12 Aug 18:24:58 ERROR [org.geotools.renderer.lite] - java.util.HashMap cannot be cast to org.opengis.feature.simple.SimpleFeature
java.lang.ClassCastException: java.util.HashMap cannot be cast to org.opengis.feature.simple.SimpleFeature
    at org.geotools.data.wfs.internal.parsers.PullParserFeatureReader.parse(PullParserFeatureReader.java:99)
    at org.geotools.data.wfs.internal.parsers.PullParserFeatureReader.parse(PullParserFeatureReader.java:46)
    at org.geotools.data.wfs.WFSFeatureReader.<init>(WFSFeatureReader.java:42)
    at org.geotools.data.wfs.WFSFeatureSource.getReaderInternal(WFSFeatureSource.java:285)
    at org.geotools.data.wfs.WFSFeatureStore.getReaderInternal(WFSFeatureStore.java:152)
    at org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:619)
    at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:163)
    at org.geoserver.feature.RetypingFeatureCollection.features(RetypingFeatureCollection.java:45)
    at org.geoserver.feature.RetypingFeatureCollection.features(RetypingFeatureCollection.java:45)
    at org.geoserver.feature.RetypingFeatureCollection.features(RetypingFeatureCollection.java:1)
    at org.geotools.data.crs.ForceCoordinateSystemFeatureResults.openIterator(ForceCoordinateSystemFeatureResults.java:92)
    at org.geotools.feature.collection.AbstractFeatureCollection.features(AbstractFeatureCollection.java:65)
    at org.geotools.feature.collection.AbstractFeatureCollection.features(AbstractFeatureCollection.java:50)
    at org.geoserver.security.decorators.SecuredFeatureCollection.features(SecuredFeatureCollection.java:43)
    at org.geoserver.security.decorators.SecuredSimpleFeatureCollection.features(SecuredSimpleFeatureCollection.java:74)
    at org.geoserver.security.decorators.SecuredSimpleFeatureCollection.features(SecuredSimpleFeatureCollection.java:1)
    at org.geotools.renderer.lite.StreamingRenderer.drawPlain(StreamingRenderer.java:2627)

The capabilities , describe feature type response and get feature response have been validated and are correct. PFA attached in this issue.

Sample WFS Responses Zip File Download

nmco commented 3 years ago

Reading the client feedback and your note @imranrajjad something does match up, looks like he was able to to consume form the remote server but the axis where inverted. Don't do anything else for this ticket, I will investigate what's going on.

nmco commented 3 years ago

The remote layer is declared as this on the ẀFS 2.0 remote capabilities document:

<FeatureTypeList>
  <FeatureType>
    <Name>ge:geoloska_jedinica</Name>
    <Title>geoloska_jedinica</Title>
    <Abstract>Geoloske jedinice</Abstract>
    <ows:Keywords>
      <ows:Keyword>features</ows:Keyword>
      <ows:Keyword>geoloska_jedinica</ows:Keyword>
    </ows:Keywords>
    <DefaultCRS>urn:ogc:def:crs:EPSG::3908</DefaultCRS>
    <ows:WGS84BoundingBox>
      <ows:LowerCorner>16.17234329924914 42.527893137531606</ows:LowerCorner>
      <ows:UpperCorner>19.676547940883342 45.2950207711989</ows:UpperCorner>
    </ows:WGS84BoundingBox>
  </FeatureType>
</FeatureTypeList>

GeoServer when reading the capabilities document will interpret it as EPSG:3908:

image

Since the SRS representation will influence the axis order, this looks like the root cause of the issue or at least creates some confusion.

When configuring the layer using WFS 1.1.0, this is the request that will be send by GeoServer tot he remote WFS server:

https://geoportal.prointer.ba/geoserver/ge/wfs?PROPERTYNAME=id%2Cgeom&TYPENAME=ge%3Ageoloska_jedinica&REQUEST=GetFeature&RESULTTYPE=RESULTS&OUTPUTFORMAT=text%2Fxml%3B+subtype%3Dgml%2F3.1.1&VERSION=1.1.0&MAXFEATURES=1&SERVICE=WFS

When configuring the layer using WFS 2.0.0, this is the request that will be send by GeoServer tot he remote WFS server:

https://geoportal.prointer.ba/geoserver/ge/wfs?PROPERTYNAME=id&REQUEST=GetFeature&RESULTTYPE=RESULTS&OUTPUTFORMAT=application/gml+xml;+version=3.2&VERSION=2.0.0&TYPENAMES=ge:geoloska_jedinica&SERVICE=WFS

... and as @Imran reported above an exception will be thrown, not clear why.

I give it a try with GeoServer 2.17.1 which is the version the client is using, and the same situation happens.