Created at:

Modified at:

Tomcat notes

Deployment of a web application (WAR) in Tomcat

A quick way to deploy an application in Tomcat is just to follow this tip:

How do I deploy a WAR file in Tomcat?

1. Stop Tomcat 2. Delete existing deployments (directories of your WAR file). 3. Copy WAR file to the webapps directory in Tomcat. 4. Start Tomcat

This quick-n-dirty script does that:

    #!/bin/sh

    set -x

    export CATALINA_HOME=<your Tomcat installation>

    app=$1

    jar cvf ${app}.war ${app}
    cd ${CATALINA_HOME}/bin
    sh shutdown.sh
    cd -
    rm -rf ${CATALINA_HOME}/webapps/${app}
    mv ${app}.war ${CATALINA_HOME}/webapps/
    cd ${CATALINA_HOME}/bin
    sh startup.sh

Just call it, passing your web application directory as the first parameter::

    $ deploy-war.sh mywebapp/

Troubleshooting

Tomcat taking to long to start up. Hangs with Deploying web application directory ...

(2024-01-22)

Using Tomcat 9.0.74 and Ubuntu Linux 20.04.

If Tomcat takes a lot to start, with no CPU usage, and last line of its startup logs is Deploying web application directory, it is probably because it is waiting for the system to have more entropy.

Try passing the -Djava.security.egd=file:/dev/./urandom option when starting it, so we use a non-blocking device as entropy source.

tomcat - Tomcat 7 hangs on deploying apps