I have a GeoServer installation on top of a PostGIS database. I am trying to set up a leaflet webmap (using Leaflet WFS-T plugin) so that I can insert, update and delete polygon features. I have managed to get this to work fine for Point features but something seems to be going wrong when inserting polygons.

Below is the request payload to GeoServer:

<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0">
<wfs:Insert><schememapper:geoserver-polygons xmlns:schememapper="schememapper">
<schememapper:geom><gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326" srsDimension="2">
<gml:exterior><gml:LinearRing srsDimension="2"><gml:posList>-1.3735914230346682 52.03958374014823 -1.9696426391601565 50.929466759820585 -3.7992525100708012 51.977294016543425 -1.3735914230346682 52.03958374014823</gml:posList>

And this is the response:

<?xml version="1.0" encoding="UTF-8"?><ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows">
<ows:Exception exceptionCode="InvalidParameterValue">
<ows:ExceptionText>Error performing insert: java.lang.String cannot be cast to org.locationtech.jts.geom.Geometry</ows:ExceptionText>

When I look at the geometry type in PostGIS it says it is MultiPolygon so I am conscious that the WFST request is only specifying 'polygon'.

Below is my Leaflet code (I am using Leaflet draw to create the polygons):

var wfstPoly = new L.WFST({
    url: 'http:localhost:8080/geoserver/ows',
//typeNS is the workspace in geoserver
    typeNS: 'schememapper',
    typeName: 'geoserver-polygons',
    crs: L.CRS.EPSG4326,
    geometryField: 'geom',
    style: {
      color: 'blue',
      weight: 2
    .once('load', function () {
      // map.fitBounds(wfstPoly);

// Drawing
var drawControl = new L.Control.Draw({ 
    draw:{circle:false, circlemarker:false, rectangle:false,
    edit:{featureGroup: wfstPoly } });

map.on('draw:created', function (e) {
    var layer = e.layer;

map.on('draw:edited', function (e) {
    var layers = e.layers;
    layers.eachLayer( function (layer) {

// Save button
L.easyButton('fa-save', function () {
     }, 'Save changes').addTo(map);

Furthermore, when I use the console to look at the original features pulled from GeoServer they are GeoJSON but when I look at the newly created features they don't seem to be. They just have an array of coordinates.

EDIT: This may have something to do with GML versions. I.E. Geoserver is expecting the XML of the request to be structured differently.

  • I think you will have more success posting this in stackoverflow directly as this seems to be more of a javascript problem than georelated
    – Leo
    Commented Jan 30, 2020 at 17:06
  • 1
    It was bug in Leaflet-WFST. Commented it on github plugin repo.
    – kuzkok
    Commented Jan 31, 2020 at 12:36
  • 1
    Did following the github repo help you fix the problem? Seems that an update to the JS library fixes the problem. If so, might assign the bounty to kuzkok.
    – Sorin RUSU
    Commented Feb 1, 2020 at 11:09
  • It did! Is it possible to assign a bounty to a comment?
    – Jamie
    Commented Feb 2, 2020 at 15:31
  • 1
    @kuzkok, can you please move your comment as an answer with some context considering the issue is about a bug?
    – fatih_dur
    Commented Feb 3, 2020 at 7:37

1 Answer 1


When you store geometry in 'Multi' postgis types, geoserver also expects this 'Multi' in transaction query. Leaflet-WFST plugin can create Multi-geometry requests on simple geometries by option 'forceMulti', this option available since v2.0.1-beta.18

var wfstPoly = new L.WFST({
    forceMulti: true

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.