* ERROR 2019-07-14 20:09:56,240 Context initialization failed (ContextLoader.java [RMI TCP Connection(2)-127.0.0.1])
java.lang.IllegalStateException: Properties could not be loaded
at org.hisp.dhis.external.conf.DefaultDhisConfigurationProvider.loadDhisConf(DefaultDhisConfigurationProvider.java:341)
at org.hisp.dhis.external.conf.DefaultDhisConfigurationProvider.init(DefaultDhisConfigurationProvider.java:110)
at org.hisp.dhis.condition.PropertiesAwareConfigurationCondition.getConfiguration(PropertiesAwareConfigurationCondition.java:57)
at org.hisp.dhis.condition.RedisEnabledCondition.matches(RedisEnabledCondition.java:49)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:447)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:436)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:436)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:128)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:327)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:400)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4682)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5143)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1728)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:457)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:406)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
at java.security.AccessController.doPrivileged(Native Method)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.hisp.dhis.external.location.LocationManagerException: External directory not set
at org.hisp.dhis.external.location.DefaultLocationManager.buildDirectory(DefaultLocationManager.java:233)
at org.hisp.dhis.external.location.DefaultLocationManager.getFileForReading(DefaultLocationManager.java:163)
at org.hisp.dhis.external.location.DefaultLocationManager.getInputStream(DefaultLocationManager.java:136)
at org.hisp.dhis.external.location.DefaultLocationManager.getInputStream(DefaultLocationManager.java:129)
at org.hisp.dhis.external.conf.DefaultDhisConfigurationProvider.loadDhisConf(DefaultDhisConfigurationProvider.java:330)
... 65 more
Hi @girishm,
You might need to install your DHIS2 instance properly; (which version are you installing?)
Set the DHIS2_HOME environment variable as stipulated on the setup instructions and links you can find on this thread; Installing DHIS2 on a Windows Local Server. Also
Let us know if this persists.
Best,
James.
Hi @jomutsani,
I have been following the contribution guidelines as mentioned here.
I have cloned the repo and was able to build the project successfully using Maven. The deployment of dhis2.war in Tomcat is not working and the above exception is thrown. Also, localhost:8080/dhis gives a 404 Not Found error. I have followed all the steps as mentioned in the document for local-setup.
Current setup:
OS: Fedora OS v30
Java: OpenJDK 1.8
Tomcat: 9.0.22
Hi @girishm. Most probably, there is problem either with DHIS2_HOME variable or with Postgresql user name and password in the dhis.conf and/or hibernate.properties file. Ensure that DHIS2_HOME variable is properly set in your environment and that user name and password in both configuration files match user name and password of your postgres database. Czech if you can connect the database usign this configuration - additionally have a look into your pg_hba.conf file if the authentication i properly set.
Hi @girishm, Since you have used this guide to build your war file, have you tried using this afterwards?
Instead of having to download war file from the site as wget, you use the compiled dhis.war file which you have to rename as ROOT.war as go on to your installation.
this is insightful; thank you @dhec and @Hynek_Kruzik for your contribution. @girishm - kindly confirm if the suggestions above have been of assistance to you.
Best,
James.
@Hynek_Kruzik, thanks for replying. I was using default H2 database as mentioned in the contribution guidelines. Should I stick to postgres database for it to work?
Dear girishm,
H2 database should work in principal with DHIS2. However, I have never used it in the production environment thus cannot share any experince. At the other hand postgres database engine has been used in many DHIS2 implementation and it is open source as well. Community members could give you better support in this case.
But you are free to experiment
Hynek
@Hynek_Kruzik @girishm Please note that only Postgres is the supported database since DHIS V2.29. The entire functionality of dhis2 may not be supported if using any other database.
Hi All,
Please follow the below instructions to install dhis2 properly on Linux based systems.
Install Java 8
sudo apt-get install openjdk-8-jdk
Install PostgreSQL
sudo apt-get install postgresql-10 postgresql-contrib-10 postgresql-10-postgis-2.4
sudo -u postgres createuser -SDRP dhis
Create database & PostGIS extension in PostgreSQL
sudo -u postgres createdb -O dhis dhis2
sudo -u postgres psql -c “create extension postgis;” dhis2
Open /etc/postgresql/10/main/postgresql.conf file and set “max_locks_per_transaction = 1024”
Restart PostgresSQL by command : sudo service postgresql restart
Creating DHIS2 configuration file
sudo -u dhis nano /home/dhis/config/dhis.conf
Copy the below lines in dhis.config
connection.dialect = org.hibernate.dialect.PostgreSQLDialect
connection.driver_class = org.postgresql.Driver
connection.url = jdbc:postgresql:dhis2
connection.username = dhis
connection.password = dhis
connection.schema = update
encryption.password = abcd
Install Tomcat & setup for dhis2
sudo apt-get install tomcat8-user
sudo nano /opt/apache-tomcat-8.5.41/bin/setenv.sh
Copy the lines to setenv.sh:
export JAVA_HOME=‘/usr/lib/jvm/java-8-openjdk-amd64/’
export JAVA_OPTS=‘-Xmx2048m -Xms1024m’ //Change accordingly
export DHIS2_HOME=‘/home/dhis/config’
Copy the dhis.war inside /opt/apache-tomcat-8.5.41/webapps
(You can download it from Downloads - DHIS2)
Start Tomcat
cd /opt/apache-tomcat-8.5.41/bin
./startup.sh
Access dhis2 web application
http://IP_OF_YOUR_SERVER:8080/dhis
I’m unable to find a match for postgresql-contrib-10
and postgresql-10-postgis-2.4
in the dnf or yum repositories for Fedora 30. Can you please share the repository sources for these installations on Fedora Linux?
Thanks for the installation guidelines @MohsinAnsari. I presume it works well for Debian based systems such as Ubuntu. However, it may need few tweaks to make it work for all Linux based systems especially Red Hat based distributions such as Fedora, CentOS etc.
Setup Yum Repository & Install PostgreSQL on Fedora
rpm -Uvh https://yum.postgresql.org/11/fedora/fedora-30-x86_64/pgdg-fedora-repo-latest.noarch.rpm
sudo dnf install postgresql11-server
/usr/pgsql-11/bin/postgresql-11-setup initdb
Start PostgreSQL Server & verify installation
sudo systemctl enable postgresql-11.service
sudo systemctl start postgresql-11.service
su - postgres -c “psql”
Setup and configuration of pgAdmin 4 on Fedora
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/F-30/pgdg-fedora-repo-latest.noarch.rpm
sudo dnf -y update && sudo dnf -y install pgadmin4
sudo systemctl start httpd && sudo systemctl enable httpd
sudo systemctl status httpd
sudo cp /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf
sudo httpd -t
sudo systemctl restart httpd
sudo mkdir -p /var/lib/pgadmin4/ /var/log/pgadmin4/
sudo vi /usr/lib/python3.7/site-packages/pgadmin4-web/config_distro.py
Add at the end of file below lines:-
LOG_FILE = ‘/var/log/pgadmin4/pgadmin4.log’
SQLITE_PATH = ‘/var/lib/pgadmin4/pgadmin4.db’
SESSION_DB_PATH = ‘/var/lib/pgadmin4/sessions’
STORAGE_DIR = ‘/var/lib/pgadmin4/storage’
sudo python3 /usr/lib/python3.7/site-packages/pgadmin4-web/setup.py
sudo chown -R apache:apache /var/lib/pgadmin4 /var/log/pgadmin4
If SELinux running
sudo semanage fcontext -a -t httpd_sys_rw_content_t “/var/lib/pgadmin4(/.)?"
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/log/pgadmin4(/.)?”
sudo restorecon -R /var/lib/pgadmin4/
sudo restorecon -R /var/log/pgadmin4/
sudo systemctl restart httpd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
http://YOUR_IP/pgadmin4
Thanks @MohsinAnsari. It works fine
Hi @MohsinAnsari,
I have just come across your post about DHIS 2 Installation. I see it was posted in 2019. I have Installed ubuntu 24.04 on my laptop. Are the same steps valid for this Ubuntu version?
Thanks
Although the post has helpful information, like you mentioned it’s from 2019 so it doesn’t have the latest versions and updates. Would you kindly have a look at the official instructions from the DHIS2 Documentation: Manual install on Ubuntu - DHIS2 Documentation
For now, I will close this topic post because it’s old; however, if you have any questions about the instructions or the information from the documentation, please feel free to create a new topic.
Thank you for your understanding. I hope the docs page helps. Again, please feel free to create a new topic post if anything is not clear.
Thanks!
Closed because topic is old.
Please refer to the latest instructions: Manual install on Ubuntu - DHIS2 Documentation