[Geoserver-users] Transactions in Geoserver - Is it possible to know which "action" failed?

Hi,

I posted a question on the GIS StackExchange group : http://gis.stackexchange.com/questions/99966/transactions-in-geoserver-wfs-is-it-possible-to-know-which-action-failed .

I was told maybe I could get more informations by asking on this mailing list!

To resume the question :

I’m using Java to send queries to Geoserver using plain HTTP POST requests.

I have a bunch of actions (Insert, Update, Delete) that I need to be transactional. If one fails, none should be commited.

Ideally, I’d like to be able to controle the transaction “externally” : To start a transaction, to make multiple requests to the Geoserver (one request per action), then to commit or rollback the transaction, by myself. Is it possible? I had a quick look at Geotools client and it seems to provide such kind of external transaction control. How does it do it?

If controlling the transaction externally is not possible, I guess I have to wrap all the actions that need to be transactional in a single wfs:Transaction element and send that in a single request.

For example :

On Thu, Jun 5, 2014 at 3:33 PM, electrotype <electrotype@anonymised.com> wrote:

That could be acceptable for my application. But the problem is GeoServer
doesn't return enough information when an error occures. For example, if
the second Insert fails, here is the kind of response Geoserver returns :

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

<?xml version="1.0" ?>
<ServiceExceptionReport
   version="1.2.0"
   xmlns="http://www.opengis.net/ogc&quot; <http://www.opengis.net/ogc&gt;
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; <http://www.w3.org/2001/XMLSchema-instance&gt;
   xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd&quot; <http://www.opengis.net/ogchttp://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd&gt;&gt;

    <ServiceException>
        java.lang.RuntimeException: Parsing failed for DIAMETRE: java.lang.NumberFormatException Parsing failed for DIAMETRE: java.lang.NumberFormatException
        null
    </ServiceException>

</ServiceExceptionReport>

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

Given the nature of the error, I don't think it's possible, the Transaction
document is parsed as a whole, and interpreted only later, if an error
occurr during parsing,
only an error at the global level is feasible, as the request contents are
still not interpreted.
If instead we are talking about errors happening during the actual write on
the data, then using the handle attribute should do the trick

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

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

Ok, I see.

And what about the “externally managed” transactions? How does the Geotools client do it, do you know?

Thanks for your help!

Julien

···

On 6/5/2014 9:46 AM, Andrea Aime wrote:

On Thu, Jun 5, 2014 at 3:33 PM, electrotype <electrotype@anonymised.com> wrote:

That could be acceptable for my application. But the problem is GeoServer doesn’t return enough information when an error occures. For example, if the second Insert fails, here is the kind of response Geoserver returns :


<?xml version="1.0" ?>
<ServiceExceptionReport
   version="1.2.0"
   xmlns=["http://www.opengis.net/ogc"](http://www.opengis.net/ogc)
   xmlns:xsi=["http://www.w3.org/2001/XMLSchema-instance"](http://www.w3.org/2001/XMLSchema-instance)
   xsi:schemaLocation=["http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd"](http://www.opengis.net/ogchttp://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd)>
    
    <ServiceException>
        java.lang.RuntimeException: Parsing failed for DIAMETRE: java.lang.NumberFormatException Parsing failed for DIAMETRE: java.lang.NumberFormatException
        null
    </ServiceException>

</ServiceExceptionReport>

Given the nature of the error, I don’t think it’s possible, the Transaction document is parsed as a whole, and interpreted only later, if an error occurr during parsing,
only an error at the global level is feasible, as the request contents are still not interpreted.
If instead we are talking about errors happening during the actual write on the data, then using the handle attribute should do the trick

Cheers
Andrea

==

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

==

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Thu, Jun 5, 2014 at 3:55 PM, electrotype <electrotype@anonymised.com> wrote:

Ok, I see.

And what about the "externally managed" transactions? How does the
Geotools client do it, do you know?

It would just fail globally as it does in your case. To avoid this
particular error you just need to modify
your client to build valid transactions, the one you're posting is not.

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

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

Andrea nailed it, transactions work as a single request. You can use “handles” as a note to yourself on what was being performed.

One last thing that gets missed is that transaction can work against more than one data source in a single go.

Finally if you have more then one editor you can start to look at “locking” the data you want to work with, and then referring the lock during your transaction.

···

Jody Garnett

On Thu, Jun 5, 2014 at 11:33 PM, electrotype <electrotype@anonymised.com> wrote:

Hi,

I posted a question on the GIS StackExchange group : http://gis.stackexchange.com/questions/99966/transactions-in-geoserver-wfs-is-it-possible-to-know-which-action-failed .

I was told maybe I could get more informations by asking on this mailing list!

To resume the question :

I’m using Java to send queries to Geoserver using plain HTTP POST requests.

I have a bunch of actions (Insert, Update, Delete) that I need to be transactional. If one fails, none should be commited.

Ideally, I’d like to be able to controle the transaction “externally” : To start a transaction, to make multiple requests to the Geoserver (one request per action), then to commit or rollback the transaction, by myself. Is it possible? I had a quick look at Geotools client and it seems to provide such kind of external transaction control. How does it do it?

If controlling the transaction externally is not possible, I guess I have to wrap all the actions that need to be transactional in a single wfs:Transaction element and send that in a single request.

For example :


<wfs:Transaction service='WFS' version='1.0.0'                        
    xmlns:wfs='[http://www.opengis.net/wfs](http://www.opengis.net/wfs)'                                               
    xmlns:gml='[http://www.opengis.net/gml](http://www.opengis.net/gml)'                            
    xmlns:ogc='[http://www.opengis.net/ogc](http://www.opengis.net/ogc)'                            
    xmlns:xsi='[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)'             
    xsi:schemaLocation='[http://www.opengis.net/wfs](http://www.opengis.net/wfs)                    
                        [http://schemas.opengis.net/wfs/1.0.0/wfs.xsd](http://schemas.opengis.net/wfs/1.0.0/wfs.xsd)'>                                                              
    <wfs:Insert>                                                      
       [[FEATURE_TO_INSERT_1]]                                     
    </wfs:Insert> 
                                                    
    <wfs:Insert>                                                      
       [[FEATURE_TO_INSERT_2]]                                     
    </wfs:Insert> 
                                                    
    <wfs:Insert>                                                      
       [[FEATURE_TO_INSERT_3]]                                     
    </wfs:Insert>                                                     

</wfs:Transaction> 

That could be acceptable for my application. But the problem is GeoServer doesn’t return enough information when an error occures. For example, if the second Insert fails, here is the kind of response Geoserver returns :


<?xml version="1.0" ?>
<ServiceExceptionReport
   version="1.2.0"
   xmlns=["http://www.opengis.net/ogc"](http://www.opengis.net/ogc)
   xmlns:xsi=["http://www.w3.org/2001/XMLSchema-instance"](http://www.w3.org/2001/XMLSchema-instance)
   xsi:schemaLocation=["http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd"](http://www.opengis.net/ogchttp://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd)>
    
    <ServiceException>
        java.lang.RuntimeException: Parsing failed for DIAMETRE: java.lang.NumberFormatException Parsing failed for DIAMETRE: java.lang.NumberFormatException
        null
    </ServiceException>

</ServiceExceptionReport>

From this response, I have no way to know which action (which “Insert”) failed. And this is something that is really problematic in my application…

Is there a way to send multiple actions in a transaction and to know which one fails when it’s the case?

Thanks in advance!

Julien


Learn Graph Databases - Download FREE O’Reilly Book
“Graph Databases” is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Since Geoserver won’t use the “handles” for some types of errors, is there a way to do prior validation before sending the request to GeoServer, so those errors can be managed “per action”? What kind of errors will prevent GeoServer to use the handles? Only those occuring when the attributes are of a wrong type?

Thank you both fo your answers.

Julien

···

On 6/5/2014 7:29 PM, Jody Garnett wrote:

Andrea nailed it, transactions work as a single request. You can use “handles” as a note to yourself on what was being performed.

One last thing that gets missed is that transaction can work against more than one data source in a single go.

Finally if you have more then one editor you can start to look at “locking” the data you want to work with, and then referring the lock during your transaction.

Jody Garnett

On Thu, Jun 5, 2014 at 11:33 PM, electrotype <electrotype@anonymised.com> wrote:

Hi,

I posted a question on the GIS StackExchange group : http://gis.stackexchange.com/questions/99966/transactions-in-geoserver-wfs-is-it-possible-to-know-which-action-failed .

I was told maybe I could get more informations by asking on this mailing list!

To resume the question :

I’m using Java to send queries to Geoserver using plain HTTP POST requests.

I have a bunch of actions (Insert, Update, Delete) that I need to be transactional. If one fails, none should be commited.

Ideally, I’d like to be able to controle the transaction “externally” : To start a transaction, to make multiple requests to the Geoserver (one request per action), then to commit or rollback the transaction, by myself. Is it possible? I had a quick look at Geotools client and it seems to provide such kind of external transaction control. How does it do it?

If controlling the transaction externally is not possible, I guess I have to wrap all the actions that need to be transactional in a single wfs:Transaction element and send that in a single request.

For example :


<wfs:Transaction service='WFS' version='1.0.0'                        
    xmlns:wfs='[http://www.opengis.net/wfs](http://www.opengis.net/wfs)'                                               
    xmlns:gml='[http://www.opengis.net/gml](http://www.opengis.net/gml)'                            
    xmlns:ogc='[http://www.opengis.net/ogc](http://www.opengis.net/ogc)'                            
    xmlns:xsi='[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)'             
    xsi:schemaLocation='[http://www.opengis.net/wfs](http://www.opengis.net/wfs)                    
                        [http://schemas.opengis.net/wfs/1.0.0/wfs.xsd](http://schemas.opengis.net/wfs/1.0.0/wfs.xsd)'>                                                              
    <wfs:Insert>                                                      
       [[FEATURE_TO_INSERT_1]]                                     
    </wfs:Insert> 
                                                    
    <wfs:Insert>                                                      
       [[FEATURE_TO_INSERT_2]]                                     
    </wfs:Insert> 
                                                    
    <wfs:Insert>                                                      
       [[FEATURE_TO_INSERT_3]]                                     
    </wfs:Insert>                                                     

</wfs:Transaction> 

That could be acceptable for my application. But the problem is GeoServer doesn’t return enough information when an error occures. For example, if the second Insert fails, here is the kind of response Geoserver returns :


<?xml version="1.0" ?>
<ServiceExceptionReport
   version="1.2.0"
   xmlns=["http://www.opengis.net/ogc"](http://www.opengis.net/ogc)
   xmlns:xsi=["http://www.w3.org/2001/XMLSchema-instance"](http://www.w3.org/2001/XMLSchema-instance)
   xsi:schemaLocation=["http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd"](http://www.opengis.net/ogchttp://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd)>
    
    <ServiceException>
        java.lang.RuntimeException: Parsing failed for DIAMETRE: java.lang.NumberFormatException Parsing failed for DIAMETRE: java.lang.NumberFormatException
        null
    </ServiceException>

</ServiceExceptionReport>

From this response, I have no way to know which action (which “Insert”) failed. And this is something that is really problematic in my application…

Is there a way to send multiple actions in a transaction and to know which one fails when it’s the case?

Thanks in advance!

Julien


Learn Graph Databases - Download FREE O’Reilly Book
“Graph Databases” is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

When you make a transaction you can include a text string called a handle, this string will show up in the logs and also in any error message returned.

I usually use this to record a client name or something so I can see what is going on with multiple users… And if there is an exception know who did it. You may also want to use the client application name, or method name or use-case.

There is no preflight check, you have access to the XML Schema to validate your content before sending. That does not protect you from the disk being full or similar.

Jody

On Friday, June 6, 2014, electrotype <electrotype@anonymised.com> wrote:

Since Geoserver won’t use the “handles” for some types of errors, is there a way to do prior validation before sending the request to GeoServer, so those errors can be managed “per action”? What kind of errors will prevent GeoServer to use the handles? Only those occuring when the attributes are of a wrong type?

Thank you both fo your answers.

Julien

On 6/5/2014 7:29 PM, Jody Garnett wrote:

Andrea nailed it, transactions work as a single request. You can use “handles” as a note to yourself on what was being performed.

One last thing that gets missed is that transaction can work against more than one data source in a single go.

Finally if you have more then one editor you can start to look at “locking” the data you want to work with, and then referring the lock during your transaction.

Jody Garnett

On Thu, Jun 5, 2014 at 11:33 PM, electrotype electrotype@anonymised.com wrote:

Hi,

I posted a question on the GIS StackExchange group : http://gis.stackexchange.com/questions/99966/transactions-in-geoserver-wfs-is-it-possible-to-know-which-action-failed .

I was told maybe I could get more informations by asking on this mailing list!

To resume the question :

I’m using Java to send queries to Geoserver using plain HTTP POST requests.

I have a bunch of actions (Insert, Update, Delete) that I need to be transactional. If one fails, none should be commited.

Ideally, I’d like to be able to controle the transaction “externally” : To start a transaction, to make multiple requests to the Geoserver (one request per action), then to commit or rollback the transaction, by myself. Is it possible? I had a quick look at Geotools client and it seems to provide such kind of external transaction control. How does it do it?

If controlling the transaction externally is not possible, I guess I have to wrap all the actions that need to be transactional in a single wfs:Transaction element and send that in a single request.

For example :


<wfs:Transaction service='WFS' version='1.0.0'                        
    xmlns:wfs='[http://www.opengis.net/wfs](http://www.opengis.net/wfs)'                                               
    xmlns:gml='[http://www.opengis.net/gml](http://www.opengis.net/gml)'                            
    xmlns:ogc='[http://www.opengis.net/ogc](http://www.opengis.net/ogc)'                            
    xmlns:xsi='[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)'             
    xsi:schemaLocation='[http://www.opengis.net/wfs](http://www.opengis.net/wfs)                    
                        [http://schemas.opengis.net/wfs/1.0.0/wfs.xsd](http://schemas.opengis.net/wfs/1.0.0/wfs.xsd)'>                                                              
    <wfs:Insert>                                                      
       [[FEATURE_TO_INSERT_1]]                                     
    </wfs:Insert> 
                                                    
    <wfs:Insert>                                                      
       [[FEATURE_TO_INSERT_2]]                                     
    </wfs:Insert> 
                                                    
    <wfs:Insert>                                                      
       [[FEATURE_TO_INSERT_3]]                                     
    </wfs:Insert>                                                     

</wfs:Transaction> 

That could be acceptable for my application. But the problem is GeoSer

Jody Garnett

On Fri, Jun 6, 2014 at 1:18 PM, electrotype <electrotype@anonymised.com> wrote:

Since Geoserver won't use the "handles" for some types of errors, is
there a way to do prior validation before sending the request to GeoServer,
so those errors can be managed "per action"? What kind of errors will
prevent GeoServer to use the handles? Only those occuring when the
attributes are of a wrong type?

Anything that prevents XML parsing, so try to respect the schema of the
feature type you're inserting,
according to the DescribeFeatureType output

Cheers
Andrea

--

Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

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

Thanks for the help!

Julien

···

On 6/7/2014 1:54 AM, Andrea Aime wrote:

On Fri, Jun 6, 2014 at 1:18 PM, electrotype <electrotype@anonymised.com> wrote:

Since Geoserver won’t use the “handles” for some types of errors, is there a way to do prior validation before sending the request to GeoServer, so those errors can be managed “per action”? What kind of errors will prevent GeoServer to use the handles? Only those occuring when the attributes are of a wrong type?

Anything that prevents XML parsing, so try to respect the schema of the feature type you’re inserting,
according to the DescribeFeatureType output

Cheers
Andrea

==
Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it