HTTP Status 404 – Not Found while installing dhis2 on ubuntu

I am geeting HTTP Status 404 error while installing DHIS2 on ubuntu. I have installed tomcat 9

My catlina.out is as follow

dhis@pfit-HP-280-G3-MT:/home/pfit$ tail -f /home/dhis/tomcat-dhis/logs/catalina.out
<6>Command line argument: -Dcatalina.base=/home/dhis/tomcat-dhis
<6>Command line argument: -Dcatalina.home=/usr/share/tomcat9
<6>Command line argument: -Djava.io.tmpdir=/home/dhis/tomcat-dhis/temp
<6>The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
<6>Initializing ProtocolHandler ["http-nio-8080"]
<6>Server initialization in [619] milliseconds
<6>Starting service [Catalina]
<6>Starting Servlet engine: [Apache Tomcat/9.0.31 (Ubuntu)]
<6>Starting ProtocolHandler ["http-nio-8080"]
<6>Server startup in [86] milliseconds

dhis.conf file is as follow

# ----------------------------------------------------------------------
# Database connection
# ----------------------------------------------------------------------

# Hibernate SQL dialect
# connection.dialect = org.hibernate.dialect.PostgreSQLDialect

# 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 = dhis

connection.schema = dhis2

# ----------------------------------------------------------------------
# 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 is as follow 

#!/bin/sh
#

export CATALINA_HOME='/usr/share/tomcat9'
echo $CATALINA_HOME
export JAVA_HOME='/usr/lib/jvm/java-11-openjdk-amd64/'
echo $JAVA_HOME
export JAVA_OPTS='-Xms4000m -Xmx7000m'
echo $JAVA_OPTS
export DHIS2_HOME='/home/dhis/config'
echo $DHIS2_HOME

# Find the Java runtime and set JAVA_HOME
/usr/libexec/tomcat9/tomcat-locate-java.sh

# Default Java options
if [ -z "$JAVA_OPTS" ]; then
	JAVA_OPTS="-Djava.awt.headless=true"
fi


startup.sh

#!/bin/sh
set -e

if [ "$(id -u)" -eq "0" ]; then
  echo "This script must NOT be run as root" 1>&2
  exit 1
fi

export CATALINA_BASE="/home/dhis/tomcat-dhis"

#export CATALINA_BASE="/home/dhis/tomcat-dhis"


/usr/share/tomcat9/bin/startup.sh
echo "Tomcat started"

echo "PWPL"

I have installed another sample war file for testing on the same server which is working properly.

Hi @Abhijit_Patil

Welcome to the community! :tada:

Sorry, you mean you were able to start dhis2 in the same Ubuntu server and everything worked well but for this war file, the issue appears?

Did you try to restart the system after the installation?

Are there more logs to share please? The full Catalina.out (without sensitive info)

I have tried some other java sample war file to check tomcat9 is working or not? we found other projects war file is working in our tomcat9 only DHIS2 is showing http status 404 error

Please find catalina.out as follows

Caused by: org.hisp.dhis.external.location.LocationManagerException: External directory not set
		at org.hisp.dhis.external.location.DefaultLocationManager.buildDirectory(DefaultLocationManager.java:303)
		at org.hisp.dhis.external.location.DefaultLocationManager.getFileForReading(DefaultLocationManager.java:233)
		at org.hisp.dhis.external.location.DefaultLocationManager.getInputStream(DefaultLocationManager.java:206)
		at org.hisp.dhis.external.location.DefaultLocationManager.getInputStream(DefaultLocationManager.java:199)
		at org.hisp.dhis.external.conf.DefaultDhisConfigurationProvider.loadDhisConf(DefaultDhisConfigurationProvider.java:332)
		... 44 more
07-Nov-2022 19:13:20.203 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/home/dhis/tomcat-dhis/webapps/ROOT.war] has finished in [22,228] ms
07-Nov-2022 19:13:20.207 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
07-Nov-2022 19:13:20.218 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [22,500] milliseconds

Hello @Abhijit_Patil first can you edit the dhis.conf to this line

connection.schema = dhis2

and put the following
connection.schema = update

restart the tomcat and see the result

1 Like

Not working for me.

Is DHIS2 working with ubuntu 20.04 with tomcat 9 and jdk-11 in local server?

It is not working for me I am trying this from last two weeks.

1 Like

Hello @Abhijit_Patil can we have a zoom call today so that we troubleshoot together what is happening ??

Thanks