1

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.
Gabriel Rogath
  • 710
  • 2
  • 8
  • 23
  • 1
    Does `ROOT.war` contain any files (its a ZIP archive and you can check it with any archive manager)? – Piotr P. Karwasz May 17 '21 at 17:11
  • Are there any errors / messages in `logs/catalina.out`? – stdunbar May 17 '21 at 17:41
  • @stdunbar. the error I can see in catalina.out is `org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]`. Thanks in advance – Gabriel Rogath May 18 '21 at 01:32
  • Yes @PiotrP.Karwasz . the `ROOT.war` contain some files. Thank in advance – Gabriel Rogath May 18 '21 at 01:33
  • Stop the server, delete the `webapps/ROOT` folder and check whether Tomcat has permissions to create files in `webapps`. If Tomcat created this folder, there would be a `META-INF/war-tracker` file in it. – Piotr P. Karwasz May 18 '21 at 05:38
  • Did this,and it's very strange that the ROOT folder is empty. – Gabriel Rogath May 18 '21 at 05:56
  • @PiotrP.Karwasz have just updated the question with more details – Gabriel Rogath May 18 '21 at 06:07
  • Is `CATALINA_BASE` equal to `CATALINA_HOME`? If it is not, you'll need to set the environment variable explicitly before running Tomcat. – Piotr P. Karwasz May 18 '21 at 06:20
  • 1
    @PiotrP.Karwasz they are not equal. `setenv.sh` for `CATALINA_HOME` is empyt and in `webapps` under `CATALINA_HOME` there are some default file and folders `docs examples host-manager manager ROOT`. As you have suggested which files should I use to set their environment variable because `setenv.sh` is not recommended as of this [link](https://tomcat.apache.org/tomcat-8.0-doc/RUNNING.txt) for `CATALINA_HOME` and `CATALINA_BASE` variables. And how do I set them. Thanks in Advance – Gabriel Rogath May 18 '21 at 06:38

1 Answers1

1

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.

Piotr P. Karwasz
  • 12,857
  • 3
  • 20
  • 43
  • There is only one file `setenv.sh` inside `CATALINA_BASE="/path/to/catalina/base" /opt/cpanel/ea-tomcat85/bin/startup.sh ` unlike `CATALINA_HOME`. How do I configure it? Thank in advance – Gabriel Rogath May 18 '21 at 07:06
  • The `startup.sh` script sources the first file that is readable between `$CATALINA_BASE/bin/setenv.sh` and `$CATALINA_HOME/bin/setenv.sh`. You just need to create the file in the correct directory (it seems that your settings could apply to any Tomcat instance, so you can put it in `$CATALINA_HOME/bin` and delete the other one). – Piotr P. Karwasz May 18 '21 at 07:39
  • Meaning that I should create these files manual in `$CATALINA_BASE/bin/`? – Gabriel Rogath May 20 '21 at 04:37
  • I thought you already created a `setenv.sh` file in the `$CATALINA_BASE/bin/` folder? – Piotr P. Karwasz May 20 '21 at 04:45
  • `setenv.sh` file is there by default, and I have set the environment as shown in the update above. I was asking about the `startup.sh `, `catalina.sh` , `shoutdown.sh` all these are not available in ` $CATALINA_BASE/bin/ ` so I cannot start tomcat from there – Gabriel Rogath May 20 '21 at 05:36
  • Call the ones you have in `$CATALINA_HOME/bin` (`/opt/cpanel/ea-tomcat85/bin` ?), but make sure to set the environment variable `CATALINA_BASE` before either using the one-liner in the answer or by calling `export CATALINA_BASE="..."` before. – Piotr P. Karwasz May 20 '21 at 05:47
  • Can you help me on how to set the environment variable on `CATALINA_BASE` as you can see in this [link](https://tomcat.apache.org/tomcat-8.0-doc/RUNNING.txt) they haven't explicitly explain about it. Or on how to `export CATALINA_BASE="..."` Thanks in advance – Gabriel Rogath May 20 '21 at 06:01
  • Use the command line I provided in the answer (of course replace `/path/to/catalina/base` with the actual path). – Piotr P. Karwasz May 20 '21 at 06:06