add features to WFS store

3 messages Options
Embed this post
Permalink
Ziegler Stefan

add features to WFS store

Reply Threaded More More options
Print post
Permalink
Hi
I'm having trouble with adding features to a WFS store. My code looks like this:

WFSFeatureStore fs = (WFSFeatureStore)datastore.getFeatureSource( typeName );
Iterator it = lines.iterator();
while(it.hasNext()) {
  String line = (String) it.next();
  feature = csv2simplefeature(line);
  if(feature != null) {
    featureColl.add(feature);
  }
}
Transaction t = new DefaultTransaction();
fs.setTransaction(t);
fs.addFeatures(featureColl);
t.commit();

It ends up with this error:

java.lang.NullPointerException
    at org.geotools.xml.wfs.WFSTransactionComplexTypes$InsertElementType.encode(WFSTransactionComplexTypes.java:922)
    at org.geotools.xml.wfs.WFSTransactionComplexTypes$TransactionType.encode(WFSTransactionComplexTypes.java:306)
    at org.geotools.xml.DocumentWriter.writeFragment(DocumentWriter.java:316)
    at org.geotools.xml.DocumentWriter.writeDocument(DocumentWriter.java:214)
    at org.geotools.data.wfs.v1_0_0.WFSTransactionState.commitPost(WFSTransactionState.java:278)
    at org.geotools.data.wfs.v1_0_0.WFSTransactionState.commit(WFSTransactionState.java:149)
    at org.geotools.data.DefaultTransaction.commit(DefaultTransaction.java:182)
    at ch.so.sogis.wabsti.SOVote.updateData(SOVote.java:156)
    at ch.so.sogis.wabsti.VoteTest.main(VoteTest.java:14)

I stumbled across bug GEOT-2081 but I'm not sure if I get it right. Does it not work with WFS 1.0.0? And if not I'm not able to find out how it should work with version 1.1.0 since there seems to be no WFSFeatureStore for version 1.1.0.
(I'm using GeoTools libraries from a GeoServer trunk from 2009-06-09).
Any hints and help is appreciated!

regards
Stefan




mit freundlichem Gruss
Stefan Ziegler

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Justin Deoliveira

Re: add features to WFS store

Reply Threaded More More options
Print post
Permalink
Hi Stefan,

I think you may have better luck with geoserver 1.7.x. I just tried some
simple tests and there seems to be some issues with the geotools wfs
client and geoserver trunk.

I have yet to track down the exact problem, but I think it involves some
recent changes to the GeoServer DescribeFeatureType output. I will let
you know when I find the exactl cause.

-Justin

Ziegler Stefan wrote:

> Hi
> I'm having trouble with adding features to a WFS store. My code looks like this:
>
> WFSFeatureStore fs = (WFSFeatureStore)datastore.getFeatureSource( typeName );
> Iterator it = lines.iterator();
> while(it.hasNext()) {
>   String line = (String) it.next();
>   feature = csv2simplefeature(line);
>   if(feature != null) {
>     featureColl.add(feature);
>   }
> }
> Transaction t = new DefaultTransaction();
> fs.setTransaction(t);
> fs.addFeatures(featureColl);
> t.commit();
>
> It ends up with this error:
>
> java.lang.NullPointerException
>     at org.geotools.xml.wfs.WFSTransactionComplexTypes$InsertElementType.encode(WFSTransactionComplexTypes.java:922)
>     at org.geotools.xml.wfs.WFSTransactionComplexTypes$TransactionType.encode(WFSTransactionComplexTypes.java:306)
>     at org.geotools.xml.DocumentWriter.writeFragment(DocumentWriter.java:316)
>     at org.geotools.xml.DocumentWriter.writeDocument(DocumentWriter.java:214)
>     at org.geotools.data.wfs.v1_0_0.WFSTransactionState.commitPost(WFSTransactionState.java:278)
>     at org.geotools.data.wfs.v1_0_0.WFSTransactionState.commit(WFSTransactionState.java:149)
>     at org.geotools.data.DefaultTransaction.commit(DefaultTransaction.java:182)
>     at ch.so.sogis.wabsti.SOVote.updateData(SOVote.java:156)
>     at ch.so.sogis.wabsti.VoteTest.main(VoteTest.java:14)
>
> I stumbled across bug GEOT-2081 but I'm not sure if I get it right. Does it not work with WFS 1.0.0? And if not I'm not able to find out how it should work with version 1.1.0 since there seems to be no WFSFeatureStore for version 1.1.0.
> (I'm using GeoTools libraries from a GeoServer trunk from 2009-06-09).
> Any hints and help is appreciated!
>
> regards
> Stefan
>
>
>
>
> mit freundlichem Gruss
> Stefan Ziegler
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Geotools-gt2-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users


--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Stefan Ziegler

Re: add features to WFS store

Reply Threaded More More options
Print post
Permalink
Hi Justin

thanks for the answer. I tried some 1.7.x versions. Same error here. I downgraded GeoTools 2.4.5 where I can add features but I'm running now into character encoding issues... Will open a new thread on this.

regards
Stefan


Justin Deoliveira wrote:
Hi Stefan,

I think you may have better luck with geoserver 1.7.x. I just tried some
simple tests and there seems to be some issues with the geotools wfs
client and geoserver trunk.

I have yet to track down the exact problem, but I think it involves some
recent changes to the GeoServer DescribeFeatureType output. I will let
you know when I find the exactl cause.

-Justin

Ziegler Stefan wrote:
> Hi
> I'm having trouble with adding features to a WFS store. My code looks like this:
>
> WFSFeatureStore fs = (WFSFeatureStore)datastore.getFeatureSource( typeName );
> Iterator it = lines.iterator();
> while(it.hasNext()) {
>   String line = (String) it.next();
>   feature = csv2simplefeature(line);
>   if(feature != null) {
>     featureColl.add(feature);
>   }
> }
> Transaction t = new DefaultTransaction();
> fs.setTransaction(t);
> fs.addFeatures(featureColl);
> t.commit();
>
> It ends up with this error:
>
> java.lang.NullPointerException
>     at org.geotools.xml.wfs.WFSTransactionComplexTypes$InsertElementType.encode(WFSTransactionComplexTypes.java:922)
>     at org.geotools.xml.wfs.WFSTransactionComplexTypes$TransactionType.encode(WFSTransactionComplexTypes.java:306)
>     at org.geotools.xml.DocumentWriter.writeFragment(DocumentWriter.java:316)
>     at org.geotools.xml.DocumentWriter.writeDocument(DocumentWriter.java:214)
>     at org.geotools.data.wfs.v1_0_0.WFSTransactionState.commitPost(WFSTransactionState.java:278)
>     at org.geotools.data.wfs.v1_0_0.WFSTransactionState.commit(WFSTransactionState.java:149)
>     at org.geotools.data.DefaultTransaction.commit(DefaultTransaction.java:182)
>     at ch.so.sogis.wabsti.SOVote.updateData(SOVote.java:156)
>     at ch.so.sogis.wabsti.VoteTest.main(VoteTest.java:14)
>
> I stumbled across bug GEOT-2081 but I'm not sure if I get it right. Does it not work with WFS 1.0.0? And if not I'm not able to find out how it should work with version 1.1.0 since there seems to be no WFSFeatureStore for version 1.1.0.
> (I'm using GeoTools libraries from a GeoServer trunk from 2009-06-09).
> Any hints and help is appreciated!
>
> regards
> Stefan
>
>
>
>
> mit freundlichem Gruss
> Stefan Ziegler
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Geotools-gt2-users mailing list
> Geotools-gt2-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users


--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users