Geoserver Tomcat


Installing Java and Tomcat8

好久没更新了,因为我在-憋-大-招-,对,就是今天这篇。 今天跟大家分享一下我的开源gis解决方案经历。-额- 考虑到单聊技术解决方案你可能会很快睡着,所以我今天会把重点放在我封装地图api这个事情上,以封装地图api的经历为线索,穿插着讲一些当时用到的开源gis架构。. GitHub GeoServer main Development. Watch this space for beta releases! If you are working closely with our development team (on the user-list or commercial support) you may be asked to test a nightly build using one of the links below. Apache Tomcat should be your first choice as it is widely adopted in the Geoserver developer’s community. If you run into any issues, the answer is probably waiting for you in the mailing list archive. We are going to install Apache Tomcat.

Geoserver does not start on tomcat 8 in linux environment. Spring bean creation of gml32FeatureTypeEncoder fires java.lang.StackOverflowError. GeoServer 2.15.0. Released on February 28th, 2019 Changelog. JIRA release 16736 Announcement.

On ubuntu install the java and tomcat8 packages

Check that you have the correct java version installed. It should be 1.8._xx.

Now install Tomcat

To check that the server is running properly, open your browser and go to http://localhost:8080.

Tuning up the Tomcat server

Edit the tomcat8 settings file

Make the following changes to JAVA_OPTS and JAVA_HOME

And restart your tomcat server

Installing Geoserver

To install geoserver, go to the GeoServer website and download the current stable web archive file to your home folder, unzip the file and copy geoserver.war to your home folder, and then copy that file to the tomcat installation as the desired name for the geoserver and restart. For example to create a geoserver called my_new_geoserver use the commands below.

Embedded Tomcat Example

You should now be able to see a geoserver running at http://localhost:8080/my_new_geoserver/ .

The geoserver will contain the example datasets that ship with Geoserver. Geoserver has good documentation available here to get you going on entering your data into your server instance.

Caching Tiles

In order for your server to perform effectively we highly recommend that you cache the tile requests from National Map. There are 2 primary ways to do this - either turning on the GeoWebCache that comes with Geoserver or running a proxy server in front of your geoserver.

The easiest solution is to just use the GeoWebCache service. The documentation for GeoWebCache is here. Mainly it consists of turning on direct integration in the caching defaults and making sure that your layers have caching turned on. You may also want to control the caching folder which can be done by editing your geoserver instance as explained here. You will also probably need to set permissions in your new cache folder to 666.

The other solution is to put a caching proxy in front of your geoserver instance. This also has the benefit of being able to access your server on port 80 if you wish. The two primary options we have worked with are nginx and varnish. These are both available as packages on ubuntu. Below is an example of setting up nginx to work with geoserver.


Then modify the configuration files to point to your server and turn on caching

and add this line at the bottom of the http section

in the servers section, comment out the root and index lines and add this line right after

and replace the location setting in the server section with the following code (replacing my_new_geoserver with your server name)

Now restart

And if all went as planned you should be able to access your server at http://localhost/my_new_geoserver/web.

Allowing National Map to access your server

Due to security in modern browsers, for National Map to use your service you will probably need to do a little more work. Either you will need to set up your server with CORS support or provide a proxy service for your geoserver to allow National Map access to your data. National Map includes a proxy to some domains by default and if you are in these domains we will provide the proxy service.

If you are not in these domains, you will get an cross-domain-access error. To work with National Map without using a proxy, Geoserver must be configured to support CORS. The most common way to do this is to install CORS Filter.

An alternative approach, is to add CORS support to your nginx or varnish proxy service. See the documentation on how to do this. Thanks to the AREMI team, adding the necessary CORS headers with a Varnish reverse-proxy in front of the Geoserver can be done by adding the following to /etc/varnish/default.vcl:

Moving your Geoserver Instance

Moving your geoserver instance to a new location is pretty straightforward. The .war file that a geoserver instance comes in is just a special layout of a .zip file. So the following commands can be used to create a .war file that you can then add to a tomcat instance on another server.

once it's uploaded to the new site you can add the geoserver with:

Running your Geoserver on AWS

Running a geoserver on a standard EC2 instance requires a little tuning to take advantage of the instance storage volume properly. First go ahead and create your instance (we use a standard m3.large instance with port 80 opened) and install java and tomcat as explained above.

Now package up your geoserver as described in the previous section and copy it up to your EC2 instance and ssh in once it's copied.

Apache Tomcat 8.0 Download

From the shell the first thing you need to do is move the webapps folder in tomcat to the instance storage.

and copy your uploaded geoserver

Geoserver Tomcat Installation

and then restart

If you are using geowebcache or a caching proxy you will need to change the caching dir as referenced above to also be on the /mnt drive to avoid running out of space on the EC2 boot drive.

NOTE: If the instance is stopped you will need to go through these step again when you start, since the instance storage is wiped clean in this case. This does not apply to reboot of the OS in the EC2 instance so it will still be fine after.

Geoserver Tomcat Installation

CORS * for GeoServer with Tomcat add following to `/var/lib/tomcat7/webapps/geoserver/WEB-INF/web.xml`

Tomcat Server Configuration

Embedded tomcat example

commented Jun 10, 2016

commented Mar 21, 2017

commented Aug 7, 2018

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment