2

I'm using GeoTools WFS package to update features in GeoServer. I don't have any problem with updating literal attributes, but when I tried to modify the geometry of features I got the following error from the log of tomcat:

org.geoserver.wfs.WFSException: Invalid value for property the_geom

I'm using following snippet of code to modify features:

String wkt = "POINT(30 40)";    
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
WKTReader reader = new WKTReader(geometryFactory);
Geometry jtsGeometry = reader.read(wkt); 

Name geoname = featureStore.getSchema().getGeometryDescriptor().getName();
Transaction transaction = new DefaultTransaction("update"); 
featureStore.setTransaction(transaction);
featureStore.modifyFeatures(geoname, jtsGeometry, filter);

transaction.commit();

Also I used FeatureWriter library and I got the same error as well.

3
  • 2
    What is the XML being sent? Is the WFS geometry called the_geom?
    – Ian Turton
    Commented Feb 26, 2023 at 15:22
  • Thanks Ian, I edited the code, I got the geometry name from the featureStore which was retrieved from WFSDataStore. As I said other parts of code is correct, because I don't have any problem with literal properties. I thought if there isn't any problem in this code, maybe I miss some special config in the geoserver, but geoserver worked correctly. I check geoserver sending a WFSTransaction XML through HTTP Post. As you said I should check generated XML request, but how could I get the xml request from the transaction or featureStrore objects? Commented Feb 26, 2023 at 20:04
  • Look in the geoserver log
    – Ian Turton
    Commented Feb 26, 2023 at 20:15

1 Answer 1

1

I resolved my problem by downgrading WFS service version in the connection parameters of WFSDataStoreFactory. By default, WFS service version is 2.0.0, which is got exception in updating geometries. I used following code to downgrade my WFS service request version:

WFSDataStoreFactory wfsDataStoreFactory = new WFSDataStoreFactory();
URL url = WFSDataStoreFactory.createGetCapabilitiesRequest(
                new URL("http://localhost:8080/geoserver/wfs"), 
                new Version("1.1.0"));
Map<String, Serializable> connectionParams = new HashMap<String, Serializable>();
connectionParams.put(WFSDataStoreFactory.URL.key, url);
connectionParams.put(WFSDataStoreFactory.USERNAME.key, "admin");
connectionParams.put(WFSDataStoreFactory.PASSWORD.key, "geoserver");

I'm using geotools version 28.1 & geoserver version 22.0. I think there is a problem in updating of geometries of WFS features using geotools featureStore.modifyFeatures method when it configured on default version of WFS (2.0.0).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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