Hi David

I tried your suggestion of changing the order, but it makes no difference:
the Feature is not saved and the GeoServer stops responding to all WFS
calls afterwards.

I've verified that I can write to this table in PostGIS, and that when I
do, I can see the results in GeoServer. I just cannot write using WFS-T.

-Harold



From:   David Winslow <[email protected]>
To:     Harold-Jeffrey Ship/Haifa/IBM@IBMIL,
Cc:     [email protected]
Date:   02/07/2012 04:50 PM
Subject:        Re: [Geoserver-users] cannot add features with WFS-T



I think that your problem is that you call FeatureCollection::addFeatures
before setting the transaction - I guess that this means your features are
being added in a different transaction than the one you have a handle to,
so when you commit there are no pending changes.  If you reverse the order
of those operations, does it work better?  It's also important to ensure
you close the transaction (just declare it outside of your try block and
close it in a finally block.)

BTW, this question would be better suited for the GeoTools users list - if
the above suggestions don't help you'll probably get better help there.

--
David Winslow
OpenGeo - http://opengeo.org/

On Sun, Jul 1, 2012 at 8:50 AM, Harold-Jeffrey Ship <[email protected]>
wrote:

  Hi

  This is my first post, and I'm new to GeoServer (and GIS).

  I'm using GeoTools 2.1.4, and trying to develop a WFS-T service which can
  add, update, delete features and of course query them. I'm using
  Java/Geotools 8.0-RC1, and originally was trying to use a shapefile to
  store the layer, but this didn't work. I tried switching to PostGIS but
  the
  problem is the same.

  The problem is this:
  When I try to commit the transaction, the commit returns successfully but
  the feature is NOT saved. Furthermore, the server no longer responds to
  requests to that layer (describeLayerType for example), until I restart
  it.

  My code looks like this:

                  String typeName =
  "postgis_runtime:runtime_postgis_layer";
                  try {
                          SimpleFeatureType schema = dataStore.getSchema
  (typeName);
                          SimpleFeatureBuilder featureBuilder = new
  SimpleFeatureBuilder(schema);
                          GeometryFactory geometryFactory =
  JTSFactoryFinder.
  getGeometryFactory(null);
                          com.vividsolutions.jts.geom.Point p =
  geometryFactory.createPoint(new Coordinate(35.0, 32.0));
                          featureBuilder.add(p);
                          featureBuilder.add("my name");
                          SimpleFeature simplefeature =
  featureBuilder.buildFeature
  (null);
                          SimpleFeatureCollection collection =
  FeatureCollections.
  newCollection();
                          collection.add(simplefeature);
                          SimpleFeatureStore store =
  (SimpleFeatureStore)dataStore.getFeatureSource(typeName);
                          Transaction t = new DefaultTransaction();
                          store.addFeatures(collection);
                          store.setTransaction(t);
                          t.commit();
                  } catch (IOException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                  }

  >From the geoserver.log, I can see the request looks like this:

  <?xml version="1.0" encoding="UTF-8"?>
  <Transaction
  xmlns:postgis_runtime="http://www.ibm.com/polaris/postgis_runtime";
  xmlns="http://www.opengis.net/wfs"; xmlns:gml="http://www.opengis.net/gml";
  xmlns:ogc="http://www.opengis.net/ogc";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://www.ibm.com/polaris/postgis_runtime
  
http://localhost:8080/geoserver/wfs?request=DescribeFeatureType&amp;SERVICE=WFS&amp;VERSION=1.0.0&amp;TYPENAME=postgis_runtime:runtime_postgis_layer
  "
   version="1.0.0" service="WFS" lockAction="ALL">
          <Insert>
                  <postgis_runtime:runtime_postgis_layer
  fid="newpostgis_runtime:runtime_postgis_layer.9223372036854775807">
                  <postgis_runtime:the_geom>
                          <gml:Point srsName="EPSG:4326">
                                  <gml:coordinates decimal="." cs="," ts="
  ">35.0,32.0</gml:coordinates>
                          </gml:Point>
                  </postgis_runtime:the_geom>
                  <gml:name>my name</gml:name>
                  </postgis_runtime:runtime_postgis_layer>
          </Insert>
  </Transaction>

  After this there is a sequence of <nul>'s in the log.

  First of all, is my code OK? If so, what can I do to get addFeatures()
  etc.
  working?


  ------------------------------------------------------------------------------

  Live Security Virtual Conference
  Exclusive live event will cover all the ways today's security and
  threat landscape has changed and how IT managers can respond. Discussions
  will include endpoint security, mobile security and the latest in malware
  threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
  _______________________________________________
  Geoserver-users mailing list
  [email protected]
  https://lists.sourceforge.net/lists/listinfo/geoserver-users



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to