Search code examples
javatomcatweb-deployment

tomcat generate empty ROOT folder but does not unpack the war file


I have gone through some post related to my question but unfortunately I have not managed to get the correct answer. I have uploaded and rename a war file to ea-tomcat85/webapps/ROOT.war in my server. But whenever I restart the tomcat server it only generate an empty ROOT folder without any files inside it. I have try to set <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> inside tomcat conf directory file server.xml as suggested in other links with no success. Also I have try to delete and rename the generated empty ROOT folder as suggested with no success. I don't know exactly what I am doing wrong or missing. This is my first time deploy a war file into a live server. Thanks in Advance.

Update

I have set the $CATALINA_BASE/bin/setenv.sh:

JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64/jre
CATALINA_PID="$CATALINA_BASE/tomcat.pid"

Just as this official link illustrate .

But when I start the server as root inside $CATALINA_HOME/bin/ I get the below output with JRE_HOME: missing environment variables.

[root@xxxx bin]# ./startup.sh
Using CATALINA_BASE:   /opt/cpanel/ea-tomcat85
Using CATALINA_HOME:   /opt/cpanel/ea-tomcat85
Using CATALINA_TMPDIR: /opt/cpanel/ea-tomcat85/temp
Using JRE_HOME:        /
Using CLASSPATH:       /opt/cpanel/ea-tomcat85/bin/bootstrap.jar:/opt/cpanel/ea-tomcat85/bin/tomcat-juli.jar
Tomcat started.

Solution

  • The only environment variable used by startup.sh that cannot be set in setenv.sh is CATALINA_BASE (if it is unset it defaults to CATALINA_HOME, which defaults to the parent folder of the startup.sh script).

    Therefore you need to start you Tomcat as:

    CATALINA_BASE="/path/to/catalina/base" /opt/cpanel/ea-tomcat85/bin/startup.sh
    

    The ROOT folder in $CATALINA_BASE/webapps was empty, since Tomcat used a different value for CATALINA_BASE.