I would like to know if there is any way for publishing existing table from postgis to geoserver using Geoserver REST API or geoserver-manager java implementation.

The thing is that i'm actually working with java, and it's sending this error message:

ERROR [geoserver.rest] - :Resource named 'aerodromos' already exists in store: 'appdemo'

However running this command from terminal works fine:

curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<featureType><name>aerodromos</name></featureType>" localhost:8080/geoserver/rest/workspaces/appdemo/datastores/appdemo/featuretypes

But then, I need to setup the xml configuration, one thing that with geoserver-manager implementation works using this code:

public boolean createLayerOnPostgisDatastore() {
    GeoserverConfig conexionGeoserver = new GeoserverConfig();

    String workspace = parametros.get("workspaceGeoserver").toString();
    String storeName = parametros.get("datastoreGeoserver").toString();
    String proyeccion = "EPSG:4326";
    GSLayerEncoder layerEncoder = new GSLayerEncoder();

    if (parametros.get("tipoGeomCapa").toString().equals("POLYGON")) {
    } else if (parametros.get("tipoGeomCapa").toString().equals("LINESTRING")) {
    } else if (parametros.get("tipoGeomCapa").toString().equals("POINT")) {
    } else if (parametros.get("tipoGeomCapa").toString().equals("MULTIPOLYGON")) {
    } else if (parametros.get("tipoGeomCapa").toString().equals("MULTILINESTRING")) {
    } else if (parametros.get("tipoGeomCapa").toString().equals("MULTIPOINT")) {

    GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
    // fte.addKeyword("TODO");
    fte.setLatLonBoundingBox(getShapeFile().getHeader().minX(), getShapeFile().getHeader().minY(), getShapeFile().getHeader().maxX(), getShapeFile().getHeader().maxY(), proyeccion);
    boolean ok = conexionGeoserver.getPublisher().publishDBLayer(workspace, storeName, fte, layerEncoder);
    return ok;

Thanks in advance.

  • 1
    so you need to post details of what you tried, ie. the error messages and relevant code. Update your original post with such details. – Gery Jan 13 '14 at 8:20
  • Gery any suggestions after updating my question? – rovskyhp Jan 13 '14 at 16:08
  • well not really, your code doesn't say much to me, I think the best is to track what your error message is telling you. Basically there is something named "aerodromos" already in your store named "appdemo". This is generating some sort of confliction in your setup. BTW, do you speak spanish? if so we can chat and discuss this issue, please let me know. – Gery Jan 14 '14 at 8:55
  • Yes I speak spanish, let me know when could you be available to chat, I'm from Mexico. Probably i could share my screen so you can follow my idea. – rovskyhp Jan 15 '14 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.