Super Java Host
  1. Home
  2. Guides
  3. Deploy a WAR file to Tomcat

How to deploy a WAR file to Tomcat

Copy, deploy, check the log. Here is the full path from a built WAR to a running application, and how to roll back.

1. Build the WAR

./mvnw clean package          # Maven
./gradlew war                 # Gradle

Check which namespace your code uses before deploying. A javax.servlet application needs Tomcat 9. A jakarta.servlet application needs Tomcat 10.1 or 11.

2. Copy it to the server

scp target/myapp.war you@your-server:/tmp/

3. Deploy

On a Super Java Host server one command does everything:

sudo deploy-app /tmp/myapp.war

It installs the file as ROOT.war, so the application answers at the root of your domain, and Tomcat unpacks it.

If you do it by hand on Ubuntu with the packaged Tomcat, the steps are:

sudo systemctl stop tomcat10
sudo rm -rf /var/lib/tomcat10/webapps/ROOT /var/lib/tomcat10/webapps/ROOT.war
sudo install -o tomcat -g tomcat -m 640 /tmp/myapp.war /var/lib/tomcat10/webapps/ROOT.war
sudo systemctl start tomcat10

Stopping Tomcat before you swap the file avoids half-unpacked applications and old classes staying in memory.

Context path

The name of the WAR decides the URL. shop.war is served at /shop. ROOT.war is served at /. Tomcat does not allow a literal slash in a file name, so use # for nested paths, such as api#v1.war for /api/v1.

4. Read the log

sudo journalctl -u tomcat10 -n 100 --no-pager
sudo tail -f /var/log/tomcat10/catalina.$(date +%F).log

Look for Deployment of web application archive ... has finished and for stack traces.

5. Roll back

Keep the previous WAR. If the new version fails, deploy the old file the same way. This is why you should never delete the last good build.

Common problems

  • 404 on every page: the application failed to start. Read the log for the first exception.
  • ClassNotFoundException: javax.servlet...: the namespace does not match the Tomcat version.
  • Database errors: the JDBC URL still points to the old host. Use 127.0.0.1 for a database on the same server.
  • Out of memory: raise the heap, see JVM heap settings.

Last updated October 29, 2026.

Your own Java server, billed monthly

Plans from €15.30 a month. Set up for you, or run for you.