Search code examples
environment-variablessizeshapefilegeoserver

How to change the system variable in Geoserver


I'm on Linux.I'm using postgresql - geoserver - openlayers. I want to display a shapefile with GeoServer. I store it in Postgresql and import the table on Geoserver. The size of the shapefile is 2.2GB. When I want to display my shapefile with the Openlayers viewer (on Geoserver), I have a white screen and this error is the logs:

ERROR [geoserver.ows] org.geoserver.platform.ServiceException: Rendering process failed .... Caused by: java.lang.RuntimeException: org.postgresql.util.PSQLException: ERROR: could not write to tuplestore temporary file: No space left on device where: SQL function "st_force_2d" statement 2

I saw here: https://docs.geoserver.org/stable/en/user/services/wfs/outputformats.html, that's the limit size is 2GB for shapefile but we can modify this limit changing the system variables GS_SHP_MAX_SIZE. How can I do that ? I checked on Internet but impossible to find a solution.


Solution

  • In the link you mentioned it said:

    it’s possible to modify those limits by setting the GS_SHP_MAX_SIZE and GS_DBF_MAX_SIZE system variables to a different value.

    So I think it's similar to GEOSERVER_DATA_DIR config.

    For binaries installation: You should change OS system variables. I'm not sure but, the command is something like this:

    $ export GS_SHP_MAX_SIZE=Limit of .shp size in bytes
    $ export GS_SHP_MAX_SIZE=3000000000
    

    If it didn't work search for changing system var in your Linux dist.

    For web archive installation: You should change the webserver or GeoServer configuration. There are 2 ways of doing it:

    1. Context parameter: Find and edit web.xml in WEB-INF folder. then add this context parameter at root element(<web-app> tag)
    <context-param>
        <param-name>GS_SHP_MAX_SIZE</param-name>
        <param-value>Limit of .shp size in bytes</param-value>
    </context-param>
    
    1. Java system property: It's very similar to binaries installation except you should add system variable for the webserver. If you are using tomcat add this to your system variables.
    $ export CATALINA_OPTS="-GS_SHP_MAX_SIZE=Limit of .shp size in bytes"
    $ export CATALINA_OPTS="-GS_SHP_MAX_SIZE=3000000000"
    

    Be careful about changing java system property! it will effect whole Apache tomcat and might cause problem in other web apps installed.