Configuring WAR Deployment with the Heroku CLI
Last updated May 04, 2020
Table of Contents
The Heroku Java CLI Plugin, which deploys a locally generated WAR file to Heroku, can be configured for various execution scenarios. The most commonly used are described here.
You can include additional files in your slug with the
--includes option. For example:
$ heroku war:deploy myapp.war --includes newrelic.jar:newrelic.xml
The character separating the included files is platform specific, just like File.pathSeparator. On Windows it will be
; (semi-colon) and on Mac and Linux it will be
Setting the Tomcat version
You can override the default Tomcat Webapp Runner version using the
--webapp-runner option. For example:
$ heroku war:deploy myapp.war --webapp-runner 22.214.171.124
The default version is 126.96.36.199. The version of Webapp Runner is pinned to the version of the underlying Tomcat server. Thus, version 188.8.131.52 of Webapp Runner uses version 9.0.20 of Tomcat. A list of available Tomcat Webapp Runner versions are available on Maven Central. (Older versions are available in a different Maven Central repository)
Configuring Tomcat options
You can configure how the WAR file executes on the server by setting the WEBAPP_RUNNER_OPTS configuration variable on your application. For example, you might set the following option:
$ heroku config:set WEBAPP_RUNNER_OPTS="--uri-encoding=UTF-8"
The heroku-deploy plugin uses Tomcat Webapp Runner as a container for the WAR file. Thus, all Webapp Runner options are available to the app. A full list options is described in the Webapp Runner documentation.
Configuring Java options
You can also configure the underlying JVM that runs the Tomcat container by
JAVA_OPTS configuration variable. For example, you might set the
following option to configure thread stack size:
$ heroku config:set JAVA_OPTS="-Xss512k"
However, the Heroku platform will select a good set of defaults for you.
For more information, see WAR Deployment.