2

I am using GeoServer and Boundless to build web mapping apps.

I have a feature grid that displays the selected layers' geometry/features. On load it shows the first 100 features, maxFeatures Number default is 100 - as per the documentation. So no issue there, the first 100 fetures are loaded and displayed on the map. However, when I click the button to show/retrieve the next 100 features I receive this response:

Status: 200

<ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows http://localhost:9080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd"> <ows:Exception exceptionCode="NoApplicableCode"> <ows:ExceptionText>java.lang.RuntimeException: java.io.IOException java.io.IOExceptionCannot do natural order without a primary key, please add it or specify a manual sort over existing attributes</ows:ExceptionText> </ows:Exception> </ows:ExceptionReport>

It does not load any more features, but returns status 200.

The DB table I used does have valid geometry and a primary key. Can anybody please explain why this is happening or how I can fix this?

1

With further inspection I found that my DB wasn't set up correctly as I was lead to believe.

The primary key in the database was in actual fact not a primary key, but a column set up to act as one, changing the column to a 'true' primary key and refreshing the layer in Geoserver solved the problem.

  • What if the layer is based on a view from a table that actually has a primary key? I have a case like this. I fixed all the tables with that error, but now I have a view and I still get this error. – joaorodr84 Apr 7 '16 at 12:13
  • Are you getting the exact same error? Or what error is being displayed in the network call? – Albert van Niekerk Apr 7 '16 at 12:25
  • It is the exact same error: "Cannot do natural order without a primary key, please add it or specify a manual sort over existing attributes". I think I fixed it by performing the sort manually, using the sortBy option. But it is strange, because it worked fine with GeoServer 2.6. Now, with 2.8, I get this error. – joaorodr84 Apr 7 '16 at 13:28
  • Are you trying to retrieve your data in a certain order, or trying to limit each call to a set amount of features? If the latter, then you can accomplish this by adding a count restraint. From the docs: "If the ID of the feature is unknown but you still want to limit the amount of features returned, use the count parameter for WFS 2.0.0" – Albert van Niekerk Apr 8 '16 at 7:50
  • No, I don't want to retrieve the data in order and I don't want to limit the number of retrieved features. I am trying to perform a search by keyword, so all the features that match the keyword should be returned, no matter what the order is. The problem is, with layers based on "views" (based on entities works fine) it does not work, and shows the error above. – joaorodr84 Apr 8 '16 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.