DHIS2 not starting. Instead tomcat9 home page appearing

I am a newbie to DHIS. I had installed DHIS2 (i think version 2.34) on AWS EC2 (Ubuntu 20.04/tomcat 9). After installation, the DHIS2 login page was available. We could not do much progress. But we were not able to start using it. So, i stopped the AWS instance to save cost. But when I restarted the instance, the DHIS server did not load. Instead I am getting the tomcat startup page . What could the problem and how to solve it.

I tried to stop the tomcat server (from /usr/share/tomcat/bin folder) and I get the following error

> java.io.FileNotFoundException: /usr/share/tomcat9/conf/server.xml (No such file or directory)

Then I tried to stop from /home/dhis/tomcat-dhis/bin/shutdown.sh, I get the message

Tomcat stopped
but i could still get the tomcat home page.

Then i tried sudo service tomcat9 stop, I do not get any message but the webpage stops
Wen and I restart the DHIS server from /home/dhis/tomcat-dhis/bin/startup.sh or by sudo service tomcat start, I get the the tomcat server home page with one of the line saying as
Tomcat veterans might be pleased to learn that this system instance of Tomcat is installed with CATALINA_HOME in /usr/share/tomcat9 and CATALINA_BASE in /var/lib/tomcat9, following the rules from /usr/share/doc/tomcat9-common/RUNNING.txt.gz.

Please, if somebody could help me in understanding the error, its cause and its solution.

Thanks in advance

Hey thank you @amitta for your question! I will make sure to follow up for support for your issue!

I read that the message you are seeing “Tomcat veterans…etc” means that you’ve setup tomcat successfully, would you like to make sure that the DHIS2 WAR file is in the webapps directory of Tomcat? And that you have renamed the WAR file as ROOT.war? Also, make sure you are running tomcat using user dhis
sudo -u dhis tomcat-dhis/bin/startup.sh
This is my attempt to support you, but if it doesn’t work please wait until I get one of the experts to support you!

@amitta, if it is possible please use: tail -f tomcat-dhis/logs/catalina.out to have the logs ready in case the DHIS2 expert needs them to assist you!

Thanks!

Yes we have the file ROOT.war in webapps folder which is in tomcat-dhis folder. i.e. /home/dhis/tomcat-dhis/webapps/ROOT.war

Yes we used sudo -u dhis tomcat-dhis/bin/startup.sh to start it.

Still the same result. Though i stopped the application using shudtdown.sh script and then started with startup.sh

Output on screen

Using CATALINA_BASE: /home/dhis/tomcat-dhis
Using CATALINA_HOME: /usr/share/tomcat9
Using CATALINA_TMPDIR: /home/dhis/tomcat-dhis/temp
Using JRE_HOME: /usr/lib/jvm/java-11-openjdk-amd64/
Using CLASSPATH: /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar
Tomcat started.
Tomcat started

I am NOT attaching the catalina.out file as i am not getting permission to upload being a new user

Hello @amitta ,

i think we are having two tomcat instances running in your system.

  1. Can you paste screenshot of the unix command result of ps -aef | grep tomcat
  2. Can you paste screenshot dhis.conf (after masking password)
  3. Can you paste screenshot of setenv.sh under bin directory of tomcat dir
  4. can you also share result of ls -lrt /usr/share/tomcat9/conf/server.xml

ubuntu@ip-172-31-32-237:~$ ps -aef | grep tomcat
dhis 28326 1 0 Jul17 ? 01:31:32 /usr/lib/jvm/java-11-openjdk-amd64//bin/java -Djava.util.logging.config.file=/home/dhis/tomcat-dhis/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms4000m -Xmx7000m -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar -Dcatalina.base=/home/dhis/tomcat-dhis -Dcatalina.home=/usr/share/tomcat9 -Djava.io.tmpdir=/home/dhis/tomcat-dhis/temp org.apache.catalina.startup.Bootstrap start
tomcat 29797 1 0 Jul17 ? 00:19:53 /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Djava.util.logging.config.file=/var/lib/tomcat9/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar -Dcatalina.base=/var/lib/tomcat9 -Dcatalina.home=/usr/share/tomcat9 -Djava.io.tmpdir=/tmp org.apache.catalina.startup.Bootstrap start
ubuntu 187318 187303 0 09:15 pts/0 00:00:00 grep --color=auto tomcat

dhis.conf (/home/dhis/config folder)

----------------------------------------------------------------------

Database connection

----------------------------------------------------------------------

JDBC driver class

connection.driver_class = org.postgresql.Driver

Database connection URL

connection.url = jdbc:postgresql:dhis2

Database username

connection.username = dhis

Database password

connection.password = xxxxxxxx

----------------------------------------------------------------------

Server

----------------------------------------------------------------------

Enable secure settings if deployed on HTTPS, default ‘off’, can be ‘on’

server.https = on

Server base URL

server.base.url = https://server.com/

===

setenv.sh (/home/dhis/tomcat-dhis/bin folder)

#!/bin/sh

CATALINA_HOME=/usr/share/tomcat9

Find the Java runtime and set JAVA_HOME

. /usr/libexec/tomcat9/tomcat-locate-java.sh

for dhis2

export JAVA_HOME=‘/usr/lib/jvm/java-11-openjdk-amd64/’
export JAVA_OPTS=‘-Xms4000m -Xmx7000m’
export DHIS2_HOME=‘/home/dhis/config’

Default Java options

if [ -z “$JAVA_OPTS” ]; then
JAVA_OPTS=“-Djava.awt.headless=true”
fi

Please note that the file server.xml is not in /usr/share/tomcat9/conf/server.xml but /usr/share/tomcat9/etc folder

ubuntu@ip-172-31-32-237:/home/dhis/tomcat-dhis/bin$ ls -lrt /usr/share/tomcat9/etc/server.xml
-rw-r--r-- 1 root root 7586 Oct 20 2020 /usr/share/tomcat9/etc/server.xml

Also there is another server.xml file in the /home/dhis/tomcat-dhis/conf folder

ubuntu@ip-172-31-32-237:/home/dhis/tomcat-dhis$ ls -lrt /home/dhis/tomcat-dhis/conf/server.xml
-rw-r–r-- 1 dhis dhis 7670 Jul 17 08:51 /home/dhis/tomcat-dhis/conf/server.xml

@jthomas any idea from the details i had submitted. Thanks in adavance

1 Like

so it turns out the issue was due to using 8080 for shut down port. After changing to 8005 Amit was able to login. documenting here for future readers

<Server port="8005" shutdown="SHUTDOWN">

2 Likes

@jthomas I salute your spirit! :+1: Thanks!

1 Like

where should add this

server conf xml in tomcat