As part of a project I'm working on I'm attempting to create a layer from a shapefile via GeoServer's REST API. Ostensibly the .prj file is optional, but if I upload a shapefile without the .prj I get a 500 error:
java.lang.NullPointerException
at org.geoserver.gwc.GWCCatalogListener.getGrids(GWCCatalogListener.java:388)
but on subsequent requests the layer is visible via the REST API. Certain requests such as WMS GetCapabilities also fail with NullPointerExceptions.
I think the sequence of events is something like:
1. I upload a Shapefile without the .prj info
2. GeoServer attempts to autoconfigure it, but stops halfway through since without knowing the native projection, it cannot determine the lat/long bounding box.
3. GeoServer saves the partially configured layer.
4. GeoServer fires an event to all catalog listeners, some of which (in this specific case, the GWC cache updater) assume that layers will be fully configured. An exception is thrown and converted to a 500 status. However, the layer is already saved so it sticks around in the catalog to cause more havoc where GeoServer depends on having a known projection or latlon bounding box.
This seems like undesired behavior, but I'm not totally sure what would be correct. Should GeoServer just leave the layer disabled, or make a guess at some "generic" projection, or reject the upload entirely?
I think a better sequence would be:
1. I upload a Shapefile without the .prj info
2. GeoServer attempts to autoconfigure it, but stops halfway since it cannot determine the lat/long bounding box.
3. GeoServer saves the datastore, and leaves the partially configured layer disabled. A message reflecting this is sent back to the client (bonus points if said message includes the partial configuration so the client can simply tweak the broken bits).
4. The client makes up something for the missing fields (ideally by asking the user) and sends back a complete configuration.
5. Now, and only now, the listeners are notified of the new layer.
I can put some time into constructing a patch, but would like some feedback on my proposal before I get my hands too dirty. For my specific use case, all that would be really required would be to return a more specific error message so I can distinguish partial configurations from outright failures.
--
David Winslow
OpenGeo - http://opengeo.org/