0

I want to run GeoServer 2.14 with Jetty on a Ubuntu 18.04. I copied the war-file in the webapps folder and GeoServer is responding.

Unfortunately I can not set the data directory location as described in the GeoServer docs.

I appended the following line to /etc/environment:

GEOSERVER_DATA_DIR="/opt/geoserver_data"

After logging in to the system the variable is set as expected:

#echo $GEOSERVER_DATA_DIR
/opt/geoserver_data

I also created the folder /opt/geoserver_data:

#ls -la /opt/geoserver_data
total 8
drwxr-xr-x 2 root root 4096 Nov 12 15:20 .
drwxr-xr-x 5 root root 4096 Nov 12 15:20 ..

When I restart Jetty, the first two GeoServer log lines are:

INFO [geoserver.platform] - Falling back to embedded data directory: /tmp/jetty-0.0.0.0-8080-geoserver.war-_geoserver-any-6077051313967886521.dir/webapp/data
INFO [geoserver.platform] - Falling back to embedded data directory: /tmp/jetty-0.0.0.0-8080-geoserver.war-_geoserver-any-6077051313967886521.dir/webapp/data

This is strange because according to the GeoServer source code, there should be a warning that the given folder does not exist or is not writable.

Obviously I am doing something wrong, but I have no idea what?


Based on Ian Turton's answer, I ensured that jetty is not run as root. Furthermore I start jetty now with -DGEOSERVER_DATA_DIR=/opt/geoserver_data, which is easier to handle than a system variable.

At the moment I still get the following warning messages:

WARN [geoserver.platform] - Found Java environment variable GEOSERVER_DATA_DIR set to /opt/geoserver_data , which is not writeable
INFO [geoserver.platform] - Falling back to embedded data directory: /tmp/jetty-0.0.0.0-8080-geoserver.war-_geoserver-any-1540535100624462590.dir/webapp/data

But at least the expected warning is shown. Although the fallback data directory still looks odd.

2

The most likely issue is that the user running jetty doesn't have write/execute permission to /opt/geoserver_data. If you are running jetty as root then please don't!

Next, most likely is that the user running jetty doesn't run a shell that sources /etc/environment as part of its start up.

Finally, your fallback jetty data directory looks odd, /tmp/jetty-0.0.0.0-8080-geoserver.war-_geoserver-any-6077051313967886521.dir/webapp/data looks like you have not unpacked the platform independent binary properly. I would expect to see something like /tmp/geoserver-2.14.0/data_dir if you had unpacked it in /tmp.

1

I found that a recent update to jetty9 in Ubuntu has added the entries

ProtectSystem=strict
ReadWritePaths=/var/lib/jetty9/

to

/lib/systemd/system/jetty9.service

which then prevents GeoServer from using an external data directory.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.