Skip to content

Tomcat Deployment

Hylke van der Schaaf edited this page Sep 25, 2018 · 4 revisions

Install tomcat

You can either download Tomcat from the tomcat website, or use the version of you distribution.

Add the PostgreSQL and PostGIS jars to Tomcat

Copy the Postgres JDBC jar and the postgis jar to $CATALINA_HOME/lib.

Deploy FROST-Server in Tomcat

Copy the FROST-Server-x.x.war to the tomcat webapps folder. It's best to rename the war to just FROST-Server.war to make upgrading easier when a new version is release. If you deploy the FROST-Server for the first time, a configuration file is copied to conf/Catalina/localhost/FROST-Server.xml. You need to edit this file, and set up the database connection details. If this file is not automatically copied (this depends on the Tomcat setting copyXML) you can manually copy the file from ${APPBASE}/META-INF/context.xml. The XML file needs to have the same name as the name of the war file. See https://ci.apache.org/projects/tomcat/tomcat9/docs/config/automatic-deployment.html for details.

<Resource
    name="jdbc/sensorThings" auth="Container"
    type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
    url="jdbc:postgresql://localhost:5432/sensorthings"
    username="sensorthings" password="ChangeMe"
    maxTotal="20" maxIdle="10" maxWaitMillis="-1"
    defaultAutoCommit="false"
/>

You need to change some things:

  • the url from jdbc:postgresql://database:5432/sensorthings to jdbc:postgresql://localhost:5432/sensorthings if your database runs on localhost. If your database server runs on another host, just use the hostname of your database server instead of localhost.
  • the username to what you set up for your database
  • the password to what you set up for your database
  • If you want to use String or UUID ids, change the persistence.persistenceManagerImplementationClass

After saving the file, Tomcat will automatically reload the service.

To initialise the database, go to http://localhost:8080/FROST-Server/DatabaseStatus. This should list a large number of SQL commands that the server wishes to execute in order to initialise the database. Click the Do Update button to update the database.

Done

You should now have a SensorThings API service running at: http://localhost:8080/FROST-Service/v1.0. Have a look at the other options in conf/Catalina/localhost/FROST-Server.xml to see what can be configured.