[Geoserver-users] ImageMosaic index not updating due to ClassCastException

Hi All,

Has anyone recently seen this when adding a granule to an imagemosaic?

java.lang.ClassCastException: org.geotools.jdbc.JDBCFeatureSource cannot be cast to org.geotools.data.simple.SimpleFeatureStore

at org.geotools.gce.imagemosaic.catalog.AbstractGTDataStoreGranuleCatalog.removeGranules(AbstractGTDataStoreGranuleCatalog.java:391)
at org.geotools.gce.imagemosaic.catalog.GTDataStoreGranuleCatalog.removeGranules(GTDataStoreGranuleCatalog.java:37)

As far as I can tell from here, the JDBCFeatureSource doesn’t directly implement SimpleFeatureStore, so the above is understandable. What’s not clear is how this has come about.

My datastore.properties references an existing PostGIS datastore:

StoreName=postgres

SPI=org.geotools.data.postgis.PostgisNGDataStoreFactory

Any clues or pointers would be very much appreciated.

Thank you in advance,

Andy

Geoserver version: 2.20.4

Is your source writable by the user that GeoServer is using? I think that error usually means it is read only.

Ian

On Fri, 4 Nov 2022, 16:40 Andrew Chamberlain via Geoserver-users, <geoserver-users@lists.sourceforge.net> wrote:

Hi All,

Has anyone recently seen this when adding a granule to an imagemosaic?

java.lang.ClassCastException: org.geotools.jdbc.JDBCFeatureSource cannot be cast to org.geotools.data.simple.SimpleFeatureStore

at org.geotools.gce.imagemosaic.catalog.AbstractGTDataStoreGranuleCatalog.removeGranules(AbstractGTDataStoreGranuleCatalog.java:391)
at org.geotools.gce.imagemosaic.catalog.GTDataStoreGranuleCatalog.removeGranules(GTDataStoreGranuleCatalog.java:37)

As far as I can tell from here, the JDBCFeatureSource doesn’t directly implement SimpleFeatureStore, so the above is understandable. What’s not clear is how this has come about.

My datastore.properties references an existing PostGIS datastore:

StoreName=postgres

SPI=org.geotools.data.postgis.PostgisNGDataStoreFactory

Any clues or pointers would be very much appreciated.

Thank you in advance,

Andy

Geoserver version: 2.20.4


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hi Ian,

Thanks for the prompt reply. Yes, the datastore is configured with the same user with which I populate the index in the database.

In case it matters, I’m still on versions 9.6/2.5 for Postgres/Postgis.

Thanks,

Andy

On Friday, 4 November 2022 at 16:50:42 GMT, Ian Turton ijturton@anonymised.com wrote:

Is your source writable by the user that GeoServer is using? I think that error usually means it is read only.

Ian

On Fri, 4 Nov 2022, 16:40 Andrew Chamberlain via Geoserver-users, <geoserver-users@lists.sourceforge.net> wrote:

Hi All,

Has anyone recently seen this when adding a granule to an imagemosaic?

java.lang.ClassCastException: org.geotools.jdbc.JDBCFeatureSource cannot be cast to org.geotools.data.simple.SimpleFeatureStore

at org.geotools.gce.imagemosaic.catalog.AbstractGTDataStoreGranuleCatalog.removeGranules(AbstractGTDataStoreGranuleCatalog.java:391)
at org.geotools.gce.imagemosaic.catalog.GTDataStoreGranuleCatalog.removeGranules(GTDataStoreGranuleCatalog.java:37)

As far as I can tell from here, the JDBCFeatureSource doesn’t directly implement SimpleFeatureStore, so the above is understandable. What’s not clear is how this has come about.

My datastore.properties references an existing PostGIS datastore:

StoreName=postgres

SPI=org.geotools.data.postgis.PostgisNGDataStoreFactory

Any clues or pointers would be very much appreciated.

Thank you in advance,

Andy

Geoserver version: 2.20.4


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hi Ian,

By way of an update, and for anyone else who might see this, the issue boiled down to a lack of a primary key on the table. As mentioned here, without a primary key, Geoserver will regard the table as read-only. So you were absolutely right: as far as Geoserver was concerned, the source was indeed read-only.

Finally, to allow the index to be updated, the UseExistingSchema property had to be set to false.

Thanks again,

Andy

On Friday, 4 November 2022 at 18:06:30 GMT, Andrew Chamberlain andy_chamberlain@anonymised.com wrote:

Hi Ian,

Thanks for the prompt reply. Yes, the datastore is configured with the same user with which I populate the index in the database.

In case it matters, I’m still on versions 9.6/2.5 for Postgres/Postgis.

Thanks,

Andy

On Friday, 4 November 2022 at 16:50:42 GMT, Ian Turton ijturton@anonymised.com wrote:

Is your source writable by the user that GeoServer is using? I think that error usually means it is read only.

Ian

On Fri, 4 Nov 2022, 16:40 Andrew Chamberlain via Geoserver-users, <geoserver-users@lists.sourceforge.net> wrote:

Hi All,

Has anyone recently seen this when adding a granule to an imagemosaic?

java.lang.ClassCastException: org.geotools.jdbc.JDBCFeatureSource cannot be cast to org.geotools.data.simple.SimpleFeatureStore

at org.geotools.gce.imagemosaic.catalog.AbstractGTDataStoreGranuleCatalog.removeGranules(AbstractGTDataStoreGranuleCatalog.java:391)
at org.geotools.gce.imagemosaic.catalog.GTDataStoreGranuleCatalog.removeGranules(GTDataStoreGranuleCatalog.java:37)

As far as I can tell from here, the JDBCFeatureSource doesn’t directly implement SimpleFeatureStore, so the above is understandable. What’s not clear is how this has come about.

My datastore.properties references an existing PostGIS datastore:

StoreName=postgres

SPI=org.geotools.data.postgis.PostgisNGDataStoreFactory

Any clues or pointers would be very much appreciated.

Thank you in advance,

Andy

Geoserver version: 2.20.4


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users