Custom STAC API in GeoServer -- What's wrong with my setup?

I have published my own STAC catalog using the “official” stac_fastapi package and with pgstac as catalog backend – the actual data is hosted on S3.

As far as I can tell, my service isn’t missing anything from the STAC-spec, but GeoServer seems to disagree. I can load the Catalog as a data store just fine, I can even see my Collections. However, when attempting to create a layer from any of the Collections, I get an error message that ends with:

Caused by: java.lang.NullPointerException
	at org.geotools.data.geojson.GeoJSONReader.getFeatures(GeoJSONReader.java:387)
	at org.geotools.stac.client.STACClient.search(STACClient.java:206)
	at org.geotools.stac.client.STACClient.search(STACClient.java:163)
	at org.geotools.stac.store.STACFeatureSource.buildFeatureType(STACFeatureSource.java:152)
	at org.geotools.data.store.ContentFeatureSource.getAbsoluteSchema(ContentFeatureSource.java:339)
	at org.geotools.data.store.ContentFeatureSource.getSchema(ContentFeatureSource.java:308)
	at org.geotools.stac.store.STACFeatureSource.<init>(STACFeatureSource.java:67)
	at org.geotools.stac.store.STACDataStore.createFeatureSource(STACDataStore.java:85)
	at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:338)
	at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:605)
	at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:97)
	at org.geoserver.catalog.CatalogBuilder.buildFeatureType(CatalogBuilder.java:325)
	at org.geoserver.web.data.layer.NewLayerPage.buildLayerInfo(NewLayerPage.java:421)
	... 127 more

What’s happening?

Interestingly, this public Catalog works just fine: earth-search.aws.element84.com/v1/

My Geoserver is Version 2.25.0.

Hi @sotosoul and welcome to the user forum.

GeoServer 2.25.0 is quite old!

It looks like that line is from GeoTools 31.0 file GeoJSONReader line 387:

ObjectNode node = mapper.readTree(parser);
JsonNode matchedNode = node.get("matched");
matched = matchedNode.asInt();

Looks like matchedNode is null - so something with your data is empty. I am not quite sure how the GeoJSON stuff is setup.

Looks like you are trying to output a required number, and the data either does not have that number or has the value null.

Hi Jody,
good catch. The code is still like that in the main branch, will activate only if there is a context node:
https://github.com/geotools/geotools/blob/main/modules/unsupported/geojson-core/src/main/java/org/geotools/data/geojson/GeoJSONReader.java#L381

It could indeed be tolerant to the case where context is available, but probably
filled with some other information, other than “matched”.

As usual, patches (actually, pull requests) welcomed. If anyone reading intends to make a change,
please start from the main branch (and then we can backport). See also:
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-fixes,-improvements-and-new-features-in-GeoServer,-GeoTools-and-GeoWebCache