I'm having a hard time upgrading from 35-RC to 35.0 in our Spring Boot application, presumably caused by the late schema parser changes. This application provides user functionality to load any WFS (and WMS, WMTS) services and use these to get features. I don't see anything I might have missed in the upgrade instructions, but would be happy to be corrected.

I have already added a GeoTools initializer that sets the entity resolver to an instance of
using
```java
    GeoTools.init();
Hints.putSystemDefault(Hints.ENTITY_RESOLVER, PreventLocalEntityResolver.INSTANCE);
```

We were already using PreventLocalEntityResolver on our WFS connection as a parameter. According to the documentation [https://docs.geotools.org/latest/userguide/library/metadata/geotools.html] this resolver should allow any schema access as long as it is not "local", quoting: "...only allows DTD and XML Schema references to remote resources".
Everything works as expected with 35-RC.

I have created a small/reproducer app: https://github.com/Tailormap/entityresolver-issues that demonstrates the problem (the master branch works fine using 35-RC, a PR: https://github.com/Tailormap/entityresolver-issues/pull/1 updating to 35.0 fails) The sample application retrieves a single feature from a GeoServer 3 WFS and a mapserver WFS.

I see the following 2 problems occurring:

========== Problem 1 ==========
It seems that the entity resolver that is passed to the WFS data store is ignored when parsing features, resulting in parse failures. As you can see in the stacktrace we open a datastore/connection explicitly using a PreventLocalEntityResolver parameter, but the stacktrace ends with a DefaultEntityResolver (this code path does not set the default entity resolver hint)`
I have opened https://osgeo-org.atlassian.net/browse/GEOT-7916 for this.

[INFO] Running nl.b3partners.entityresolverissues.WFSGetFeatureUtilTest
14:07:58.678 [main] INFO nl.b3partners.entityresolverissues.WFSGetFeatureUtil -- DataStore created for WFS capabilities URL: https://service.pdok.nl/kadaster/brk-bestuurlijke-gebieden/wfs/v1_0?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities using entity resolver org.geotools.util.PreventLocalEntityResolver@64bba0eb 14:07:58.681 [main] INFO nl.b3partners.entityresolverissues.WFSGetFeatureUtil -- Found the following WFS feature types: [bestuurlijkegebieden:Provinciegebied, bestuurlijkegebieden:Landgebied, bestuurlijkegebieden:Gemeentegebied] 14:08:00.693 [main] INFO nl.b3partners.entityresolverissues.WFSGetFeatureUtil -- Geometry attribute for type bestuurlijkegebieden:Provinciegebied: GeometryDescriptorImpl geom <geom:Geometry> nillable 0:1
Jun 29, 2026 2:08:03 PM org.geotools.xsd.impl.ParserHandler loadSchemas
WARNING: Error loading schema for namespace: http://bestuurlijkegebieden.geonovum.nl at location: https://service.pdok.nl/kadaster/brk-bestuurlijke-gebieden/wfs/v1_0?SERVICE=WFS&VERSION=2.0.0&REQUEST=DescribeFeatureType&TYPENAME=bestuurlijkegebieden:Provinciegebied&OUTPUTFORMAT=application%2Fgml%2Bxml%3B%20version%3D3.2 java.io.IOException: org.xml.sax.SAXException: Entity resolution disallowed for https://service.pdok.nl/kadaster/brk-bestuurlijke-gebieden/wfs/v1_0?SERVICE=WFS&VERSION=2.0.0&REQUEST=DescribeFeatureType&TYPENAME=bestuurlijkegebieden:Provinciegebied&OUTPUTFORMAT=application%2Fgml%2Bxml%3B%20version%3D3.2
        at org.geotools.xsd.Schemas.parse(Schemas.java:338)
        at org.geotools.xsd.Schemas.parse(Schemas.java:285)
        at 
org.geotools.xsd.impl.ParserHandler.loadSchemas(ParserHandler.java:592)
        at 
org.geotools.xsd.impl.ParserHandler.startElement(ParserHandler.java:343)
        at org.geotools.xsd.PullParser.parse(PullParser.java:100)
at org.geotools.data.wfs.internal.parsers.PullParserFeatureReader.parse(PullParserFeatureReader.java:124) at org.geotools.data.wfs.internal.parsers.PullParserFeatureReader.parse(PullParserFeatureReader.java:50)
        at 
org.geotools.data.wfs.WFSFeatureReader.<init>(WFSFeatureReader.java:47)
at org.geotools.data.wfs.WFSFeatureSource.getReaderInternal(WFSFeatureSource.java:294) at org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:622) at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:163) at nl.b3partners.entityresolverissues.WFSGetFeatureUtil.getOneFeature(WFSGetFeatureUtil.java:92) at nl.b3partners.entityresolverissues.WFSGetFeatureUtilTest.testWFSGetFeatureProvinciegebied(WFSGetFeatureUtilTest.java:36)
...
Caused by: org.xml.sax.SAXException: Entity resolution disallowed for https://service.pdok.nl/kadaster/brk-bestuurlijke-gebieden/wfs/v1_0?SERVICE=WFS&VERSION=2.0.0&REQUEST=DescribeFeatureType&TYPENAME=bestuurlijkegebieden:Provinciegebied&OUTPUTFORMAT=application%2Fgml%2Bxml%3B%20version%3D3.2 at org.geotools.util.DefaultEntityResolver.resolveEntity(DefaultEntityResolver.java:151) at org.geotools.util.DefaultEntityResolver.resolveEntity(DefaultEntityResolver.java:117)
        at org.geotools.xsd.Schemas.parse(Schemas.java:336)


see eg. https://github.com/Tailormap/entityresolver-issues/actions/runs/28378077747/job/84073008739?pr=1#step:4:265 for a full stack trace;

========== Problem 2 ==========
However, even when the default entity resolver is set to an instance of PreventLocalEntityResolver through the Hints/GeoTools.init() call the entity resolution is still disallowed and parsing features fails.
I have opened https://osgeo-org.atlassian.net/browse/GEOT-7922 for this.

2026-06-29T14:08:03.714Z DEBUG 2179 --- [ main] org.geotools.data.ows : Executed request to URL: https://snapshot.tailormap.nl/geoserver/wfs? 2026-06-29T14:08:03.715Z DEBUG 2179 --- [ main] org.geotools.data.wfs : response = WFSResponse[charset=UTF-8, contentType=application/gml+xml; version=3.2] 2026-06-29T14:08:03.717Z WARN 2179 --- [ main] org.geotools.xsd.impl : Error loading schema for namespace: http://tailormap.nl/geodata/postgis/ at location: https://snapshot.tailormap.nl/geoserver/wfs?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName=postgis%3Abak

java.io.IOException: org.xml.sax.SAXException: Entity resolution disallowed for https://snapshot.tailormap.nl/geoserver/wfs?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName=postgis%3Abak at org.geotools.xsd.Schemas.parse(Schemas.java:338) ~[gt-xsd-core-35.0.jar:na] at org.geotools.xsd.Schemas.parse(Schemas.java:285) ~[gt-xsd-core-35.0.jar:na] at org.geotools.xsd.impl.ParserHandler.loadSchemas(ParserHandler.java:592) ~[gt-xsd-core-35.0.jar:na] at org.geotools.xsd.impl.ParserHandler.startElement(ParserHandler.java:343) ~[gt-xsd-core-35.0.jar:na] at org.geotools.xsd.PullParser.parse(PullParser.java:100) ~[gt-xsd-core-35.0.jar:na] at org.geotools.data.wfs.internal.parsers.PullParserFeatureReader.parse(PullParserFeatureReader.java:124) ~[gt-wfs-ng-35.0.jar:na] at org.geotools.data.wfs.internal.parsers.PullParserFeatureReader.parse(PullParserFeatureReader.java:50) ~[gt-wfs-ng-35.0.jar:na] at org.geotools.data.wfs.WFSFeatureReader.<init>(WFSFeatureReader.java:47) ~[gt-wfs-ng-35.0.jar:na] at org.geotools.data.wfs.WFSFeatureSource.getReaderInternal(WFSFeatureSource.java:294) ~[gt-wfs-ng-35.0.jar:na] at org.geotools.data.wfs.WFSFeatureStore.getReaderInternal(WFSFeatureStore.java:150) ~[gt-wfs-ng-35.0.jar:na] at org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:622) ~[gt-main-35.0.jar:na] at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:163) ~[gt-main-35.0.jar:na] at nl.b3partners.entityresolverissues.WFSGetFeatureUtil.getOneFeature(WFSGetFeatureUtil.java:92) ~[classes/:na]

...
Caused by: org.xml.sax.SAXException: Entity resolution disallowed for https://snapshot.tailormap.nl/geoserver/wfs?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName=postgis%3Abak at org.geotools.util.PreventLocalEntityResolver.resolveEntity(PreventLocalEntityResolver.java:123) ~[gt-metadata-35.0.jar:na] at org.geotools.util.PreventLocalEntityResolver.resolveEntity(PreventLocalEntityResolver.java:85) ~[gt-metadata-35.0.jar:na] at org.geotools.xsd.Schemas.parse(Schemas.java:336) ~[gt-xsd-core-35.0.jar:na]
        ... 128 common frames omitted


_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to