geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
427 stars 489 forks source link

geopublication of a zipped SHP layer without projection to GS 2.18 broken in 4.0.6 #6157

Open landryb opened 2 years ago

landryb commented 2 years ago

Describe the bug trying to publish a layer to geoserver 2.18 fails

To Reproduce Steps to reproduce the behavior:

  1. configure a remote geoserver via REST
  2. Try to publish a layer

Expected behavior The layer should be published in geoserver

Log file

Sequence of events/calls between GN and GS:

"PUT /geoserver/rest/workspaces/geopub/datastores/ortho_cantal_2020/file.shp HTTP/1.1" 201 2023 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"
"GET /geoserver/rest/styles/ortho_cantal_2020_style?quietOnNotFound=true HTTP/1.1" 404 1304 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"
"POST /geoserver/rest/styles HTTP/1.1" 201 639 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"
"GET /geoserver/rest/layers/geopub:ortho_cantal_2020.xml?quietOnNotFound=true HTTP/1.1" 200 1398 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"
"GET /geoserver/rest/styles/polygon.sld?quietOnNotFound=true HTTP/1.1" 200 2041 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"
"PUT /geoserver/rest/styles/ortho_cantal_2020_style HTTP/1.1" 200 570 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"
"PUT /geoserver/rest/layers/geopub:ortho_cantal_2020 HTTP/1.1" 200 570 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"
"GET /geoserver/rest/workspaces/geopub/datastores/ortho_cantal_2020/featuretypes/ortho_cantal_2020 HTTP/1.1" 200 1248 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"
"PUT /geoserver/rest/workspaces/geopub/datastores/ortho_cantal_2020/featuretypes/ortho_cantal_2020 HTTP/1.1" 500 20659 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"
"GET /geoserver/rest/layers/geopub:ortho_cantal_2020.xml?quietOnNotFound=true HTTP/1.1" 200 1686 "-" "Apache-HttpClient/4.5.9 (Java/1.8.0_292)"

geoserver log for rest.catalog:

2022-02-09 11:43:50,643 INFO [rest.catalog] - Auto-configuring datastore: ortho_cantal_2020
2022-02-09 11:43:52,353 INFO [rest.catalog] - Added feature type ortho_cantal_2020
2022-02-09 11:43:52,467 INFO [rest.catalog] - POST style ortho_cantal_2020_style
2022-02-09 11:43:52,627 INFO [rest.catalog] - PUT layer geopub:ortho_cantal_2020

traceback of failing call in geoserver log:

09 févr. 11:43:52 ERROR [geoserver.rest] -
java.lang.NullPointerException
        at org.geoserver.catalog.ResourcePool.getFeatureSource(ResourcePool.java:1296)
        at org.geoserver.catalog.impl.FeatureTypeInfoImpl.getFeatureSource(FeatureTypeInfoImpl.java:128)
        at org.geoserver.catalog.CatalogBuilder.getNativeBounds(CatalogBuilder.java:569)
        at org.geoserver.catalog.CatalogBuilder.getNativeBounds(CatalogBuilder.java:552)
        at org.geoserver.rest.catalog.AbstractCatalogController.calculateOptionalFields(AbstractCatalogController.java:77)
        at org.geoserver.rest.catalog.FeatureTypeController.featureTypePut(FeatureTypeController.java:356)

in geoserver, the layer is listed in the list but not active and not fully configured. I'll dig into that, trying to figure out what is missing...

landryb commented 2 years ago

here's the HTML sent back by GET /geoserver/rest/workspaces/geopub/datastores/ortho_cantal_2020/featuretypes/ortho_cantal_2020 (with a 200 code):

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\r\n
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\r\n
    <head>\r\n
        <title>GeoServer Configuration</title>\r\n
        <meta name="ROBOTS" content="NOINDEX, NOFOLLOW"/>\r\n
    </head>\r\n
    <body>\r\n
    \r\n
    Feature Type "ortho_cantal_2020"\n
    \n
    <ul>\n
      <li>Name: ortho_cantal_2020</li>\n
      <li>Description: null</li>\n
      <li>Abstract: null</li>\n
      <li>Enabled: false</li>\n
      <li>SRS: null</li>\n
      <li>Bounds: ReferencedEnvelope[625000.0 : 730000.0, 6390000.0 : 6488000.0]></li> \n
    </ul>\n
      \n
    </body>\r\n
    </html>\n

here's the XML sent that triggers the error when being PUT on /geoserver/rest/workspaces/geopub/datastores/ortho_cantal_2020/featuretypes/ortho_cantal_2020

    <featureType>
        <title>
            Test geopublication
            </title>
        <abstract>
            Mon résumé a moi
            </abstract>
        <enabled>
            true
            </enabled>
        <metadataLinks>
            <metadataLink>
                <type>
                    text/xml
                    </type>
                <metadataType>
                    ISO19115:2003
                    </metadataType>
                <content>
                    https://FQDN/geonetwork/srv/fre//csw?SERVICE=CSW&amp;VERSION=2.0.2&amp;REQUEST=GetRecordById&amp;outputSchema=http://www.isotc211.org/2005/gmd&amp;ID=e731c037-8698-4b3d-b757-b4c11855b6df
                    </content>
                </metadataLink>
            <metadataLink>
                <type>
                    text/xml
                    </type>
                <metadataType>
                    TC211
                    </metadataType>
                <content>
                    https://FQDN/geonetwork/srv/fre//csw?SERVICE=CSW&amp;VERSION=2.0.2&amp;REQUEST=GetRecordById&amp;outputSchema=http://www.isotc211.org/2005/gmd&amp;ID=e731c037-8698-4b3d-b757-b4c11855b6df
                    </content>
                </metadataLink>
            <metadataLink>
                <type>
                    text/html
                    </type>
                <metadataType>
                    TC211
                    </metadataType>
                <content>
                    https://FQDN/geonetwork/srv/api/records/e731c037-8698-4b3d-b757-b4c11855b6df
                    </content>
                </metadataLink>
            </metadataLinks>
        </featureType>
landryb commented 2 years ago

Well, it was a 'doh' moment, but geopublication works with a zip that contains a layer with a valid projection, and fails with a layer which has no valid projection. Still an issue to gracefully handle i guess..

maybe checking for <li>SRS: null</li>\n in the reply received in https://github.com/geonetwork/core-geonetwork/blob/main/services/src/main/java/org/fao/geonet/api/mapservers/GeoServerRest.java#L565 ?