Startup issues in 2.34.1

I have just installed dhis2 version 2.34.1 but i am getting this error in my log;

<6>Command line argument: -Dignore.endorsed.dirs=
<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/amd64:/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 [372] milliseconds
<6>Starting service [Catalina]
<6>Starting Servlet engine: [Apache Tomcat/9.0.16 (Ubuntu)]
<6>Deploying web application archive [/home/dhis/tomcat-dhis/webapps/ROOT.war]
* INFO  2020-07-24T17:05:18,927 System property dhis2.home not set (LogOnceLogger.java [main])
 * INFO  2020-07-24T17:05:18,938 Environment variable DHIS2_HOME points to /home/dhis/config (LogOnceLogger.java [main])
 * INFO  2020-07-24T17:05:18,943 File /home/dhis/config/dhis.conf cannot be read (LogOnceLogger.java [main])
 <2>Error deploying web application archive [/home/dhis/tomcat-dhis/webapps/ROOT.war]
<2>java.lang.IllegalStateException: Error starting child
<2>    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:716)
<2>    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
<2>    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
<2>    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
<2>    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1850)
<2>    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
<2>    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
<2>    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
<2>    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
<2>    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
<2>    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
<2>    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1577)
<2>    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
<2>    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
<2>    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
<2>    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
<2>    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:929)
<2>    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
<2>    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
<2>    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
<2>    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
<2>    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
<2>    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
<2>    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
<2>    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
<2>    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
<2>    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
<2>    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
<2>    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
<2>    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
<2>    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
<2>    at org.apache.catalina.startup.Catalina.start(Catalina.java:638)
<2>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
<2>    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
<2>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
<2>    at java.lang.reflect.Method.invoke(Method.java:498)
<2>    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
<2>    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:496)
<2>Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
<2>    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441)
<2>    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
<2>    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
<2>    ... 37 more
<2>Caused by: java.lang.IllegalStateException: Properties could not be loaded
<2>    at org.hisp.dhis.external.conf.DefaultDhisConfigurationProvider.loadDhisConf(DefaultDhisConfigurationProvider.java:331)
<2>    at org.hisp.dhis.external.conf.DefaultDhisConfigurationProvider.init(DefaultDhisConfigurationProvider.java:112)
<2>    at org.hisp.dhis.configuration.SecureCookieConfiguration.getConfig(SecureCookieConfiguration.java:72)
<2>    at org.hisp.dhis.configuration.SecureCookieConfiguration.onStartup(SecureCookieConfiguration.java:54)
<2>    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)
<2>    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5125)
<2>    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
<2>    ... 38 more
<2>Caused by: org.hisp.dhis.external.location.LocationManagerException: File /home/dhis/config/dhis.conf cannot be read
<2>    at org.hisp.dhis.external.location.DefaultLocationManager.getFileForReading(DefaultLocationManager.java:179)
<2>    at org.hisp.dhis.external.location.DefaultLocationManager.getInputStream(DefaultLocationManager.java:146)
<2>    at org.hisp.dhis.external.location.DefaultLocationManager.getInputStream(DefaultLocationManager.java:139)
<2>    at org.hisp.dhis.external.conf.DefaultDhisConfigurationProvider.loadDhisConf(DefaultDhisConfigurationProvider.java:320)
<2>    ... 44 more
<2>
<6>Deployment of web application archive [/home/dhis/tomcat-dhis/webapps/ROOT.war] has finished in [12,474] ms
<6>Starting ProtocolHandler ["http-nio-8080"]
<6>Server startup in [12,521] milliseconds

Apparently the problem is that it cannot read the dhis.conf file during startup, make sure you create the dhis.conf using any text editor (i.e Notepad) and populate it with the right configuration as mentioned in the dhis installation manual and put it inside the DHIS2_HOME directory /home/dhis/config, and restart the instance

1 Like

Thanks Hamza.

My dhis.conf is Ok and also in the right location. Could there be any other reason why it can not read the dhis.conf file?

Hi @herbert_kiwalya,

As Hamza says the problem is that Tomcat cannot read your dhis.conf file. Assuming it is properly located (you have defined it in the setenv.sh pointing to /home/dhis/config/dhis.conf.

My assumption is that you probably run the chmod command with the wrong user. Or tomcat is being run with another user.

To see the permissions of the dhis.conf you could run $> ls -al dhis.conf from a terminal. And verify that the user and permissions are correct. You should see something like:
-r--------- 1 dhis dhis 413 Jul 16 17:41 dhis.conf

Thanks @jaime.bosque,

My setenv.sh is well defined and properly configured pointing to /home/dhis/config/dhis.conf

Otherwise I am seeing the root user instead of dhis. Could this be the issue?
-rw------- 1 root root 714 Jul 26 07:16 /home/dhis/config/dhis.conf

Yes, that is likely the issue. You created that file as root, and when you are launching tomcat as the user dhis the file cannot be read.

In order to fix it you will need to, as root, execute the following

$> chown dhis:dhis /home/dhis/config/dhis.conf

You can read this to fully understand what is going on: https://www.guru99.com/file-permissions.html

I have sorted out the permission issues but dhis2 still can’t start

 * ERROR 2020-07-27T10:21:26,323 javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149)
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1423)
        at org.hibernate.query.Query.getResultList(Query.java:146)
        at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:72)
        at org.hisp.dhis.hibernate.HibernateGenericStore.getList(HibernateGenericStore.java:266)
        at org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore.getAllEqName(HibernateIdentifiableObjectStore.java:467)
        at org.hisp.dhis.dataelement.DefaultCategoryService.getCategoryByName(DefaultCategoryService.java:181)
        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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
        at com.sun.proxy.$Proxy202.getCategoryByName(Unknown Source)
        at org.hisp.dhis.dataelement.DataElementDefaultDimensionPopulator.executeInTransaction(DataElementDefaultDimensionPopulator.java:88)
        at org.hisp.dhis.system.startup.TransactionContextStartupRoutine$1.doInTransaction(TransactionContextStartupRoutine.java:58)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
        at org.hisp.dhis.system.startup.TransactionContextStartupRoutine.execute(TransactionContextStartupRoutine.java:53)
        at org.hisp.dhis.system.startup.DefaultStartupRoutineExecutor.execute(DefaultStartupRoutineExecutor.java:114)
        at org.hisp.dhis.system.startup.DefaultStartupRoutineExecutor.execute(DefaultStartupRoutineExecutor.java:71)
        at org.hisp.dhis.system.startup.StartupListener.contextInitialized(StartupListener.java:70)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4668)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5136)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1850)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1577)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
        at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
        at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:929)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:638)
        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.catalina.startup.Bootstrap.start(Bootstrap.java:350)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:496)
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3032)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3547)
        at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:600)
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:474)
        at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
        at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:50)
        at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1398)
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1483)
        at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)
        ... 65 more
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "uk_4pi5lfmisrt8un89dnb17xrdy"
  Detail: Key (uid)=(xYerKDKCefk) already exists.
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
        at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:120)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:1502)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
        ... 76 more
 (StartupListener.java [main])
 <2>One or more listeners failed to start. Full details will be found in the appropriate container log file
* INFO  2020-07-27T10:21:26,362 'system-process' update org.hisp.dhis.category.CategoryOption, name: default, uid: xYerKDKCefk (AuditLogUtil.java [main])
 * INFO  2020-07-27T10:21:26,363 'system-process' create org.hisp.dhis.category.Category, name: default, uid: GLevLNI9wkl (AuditLogUtil.java [main])
 * INFO  2020-07-27T10:21:26,380 'system-process' update org.hisp.dhis.category.Category, name: default, uid: GLevLNI9wkl (AuditLogUtil.java [main])
 * INFO  2020-07-27T10:21:26,381 'system-process' create org.hisp.dhis.category.CategoryCombo, name: default, uid: bjDvmb4bfuf (AuditLogUtil.java [main])
 * INFO  2020-07-27T10:21:26,383 'system-process' update org.hisp.dhis.category.CategoryCombo, name: default, uid: bjDvmb4bfuf (AuditLogUtil.java [main])
 * INFO  2020-07-27T10:21:26,383 'system-process' create org.hisp.dhis.category.CategoryOptionCombo, name: default, uid: HllvX50cXC0 (AuditLogUtil.java [main])
 * INFO  2020-07-27T10:21:26,384 'system-process' update org.hisp.dhis.category.CategoryOptionCombo, name: default, uid: HllvX50cXC0 (AuditLogUtil.java [main])
 * INFO  2020-07-27T10:21:26,385 'system-process' update org.hisp.dhis.category.CategoryCombo, name: default, uid: bjDvmb4bfuf (AuditLogUtil.java [main])
 * INFO  2020-07-27T10:21:26,385 'system-process' update org.hisp.dhis.category.CategoryOption, name: default, uid: xYerKDKCefk (AuditLogUtil.java [main])
 * INFO  2020-07-27T10:21:26,385 Executing startup routine [2 of 9, runlevel 2]: PeriodTypePopulator (DefaultStartupRoutineExecutor.java [main])
 * WARN  2020-07-27T10:21:26,390 Cannot get users with disjoint roles as user does not have any user roles (DefaultUserService.java [main])
 * INFO  2020-07-27T10:21:26,391 Executing startup routine [3 of 9, runlevel 3]: DataElementDefaultDimensionPopulator (DefaultStartupRoutineExecutor.java [main])
 * INFO  2020-07-27T10:21:26,470 'system-process' update org.hisp.dhis.category.Category, name: default, uid: GLevLNI9wkl (AuditLogUtil.java [main])
 * WARN  2020-07-27T10:21:26,495 SQL Error: 0, SQLState: 23505 (SqlExceptionHelper.java [main])
 * ERROR 2020-07-27T10:21:26,496 ERROR: duplicate key value violates unique constraint "uk_4pi5lfmisrt8un89dnb17xrdy"
  Detail: Key (uid)=(xYerKDKCefk) already exists. (SqlExceptionHelper.java [main])
 * WARN  2020-07-27T10:21:26,502 onPostInsertCommitFailed: org.hibernate.event.spi.PostInsertEvent@74fddef4 (PostInsertAuditListener.java [main])
 * ERROR 2020-07-27T10:21:26,504 javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149)
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1423)
        at org.hibernate.query.Query.getResultList(Query.java:146)
        at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:72)
        at org.hisp.dhis.hibernate.HibernateGenericStore.getList(HibernateGenericStore.java:266)
        at org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore.getAllEqName(HibernateIdentifiableObjectStore.java:467)
        at org.hisp.dhis.dataelement.DefaultCategoryService.getCategoryByName(DefaultCategoryService.java:181)
        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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
        at com.sun.proxy.$Proxy202.getCategoryByName(Unknown Source)
        at org.hisp.dhis.dataelement.DataElementDefaultDimensionPopulator.executeInTransaction(DataElementDefaultDimensionPopulator.java:88)
        at org.hisp.dhis.system.startup.TransactionContextStartupRoutine$1.doInTransaction(TransactionContextStartupRoutine.java:58)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
        at org.hisp.dhis.system.startup.TransactionContextStartupRoutine.execute(TransactionContextStartupRoutine.java:53)
        at org.hisp.dhis.system.startup.DefaultStartupRoutineExecutor.execute(DefaultStartupRoutineExecutor.java:114)
        at org.hisp.dhis.system.startup.DefaultStartupRoutineExecutor.execute(DefaultStartupRoutineExecutor.java:71)
        at org.hisp.dhis.system.startup.StartupListener.contextInitialized(StartupListener.java:70)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4668)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5136)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1850)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1577)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
        at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
        at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:929)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:638)
        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.catalina.startup.Bootstrap.start(Bootstrap.java:350)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:496)
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3032)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3547)
        at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:600)
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:474)
        at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
        at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:50)
        at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1398)
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1483)
        at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)
        ... 65 more
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "uk_4pi5lfmisrt8un89dnb17xrdy"
  Detail: Key (uid)=(xYerKDKCefk) already exists.
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
        at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:120)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:1502)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
        ... 76 more

Are you using one of the testing databases? It seems there are some errors with it… If you have no important data I would advise to dump the database and load another one with same version as the DHIS2.

https://www.dhis2.org/downloads (Check sample data section)

Thanks @jaime.bosque

I am shifting my instance to another server. I have managed to do everything right but now when starting dhis2 it usually stops at;
* INFO 2020-07-28T18:10:24,882 All startup routines done (DefaultStartupRoutineExecutor.java [main])

I expect a normal log to get to;
<6>Deployment of web application archive [/home/dhis/tomcat-dhis/webapps/demo.war] has finished in [705,788] ms <6>Starting ProtocolHandler ["http-nio-8080"] <6>Server startup in [705,850] milliseconds

Also when i stop tomcat, i get this;
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-1.8.0-openjdk-amd64/ Using CLASSPATH: /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar Jul 28, 2020 6:24:13 PM org.apache.catalina.startup.Catalina stopServer SEVERE: Could not contact [localhost:8005] (base port [8005] and offset [0]). Tomcat may not be running. Jul 28, 2020 6:24:13 PM org.apache.catalina.startup.Catalina stopServer SEVERE: Error stopping Catalina java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:607) at java.net.Socket.connect(Socket.java:556) at java.net.Socket.<init>(Socket.java:452) at java.net.Socket.<init>(Socket.java:229) at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:514) 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.catalina.startup.Bootstrap.stopServer(Bootstrap.java:403) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:501)

Uhhmmm, sorry @herbert_kiwalya. From the logs I cannot really see what’s going on.

Have you followed the installation guide from the official documentation: https://docs.dhis2.org/2.34/en/dhis2_system_administration_guide/installation.html?

I only can start by root. if not:
al-Jul-2020 10:36:09.861 信息 [Thread-2 (activemq-netty-threads)] org.apache.cat
ina.loader.WebappClassLoaderBase.checkStateForResourceLoading 非法访问:此Web应
。无法加载[io.netty.util.concurrent.DefaultPromise$1]。为了调试以及终止导致非法
加载[io.netty.util.cteException: 非法访问:此Web应用程序实例已停止。无法
oncurrent.DefaultPromise$1]。为了调试以及终止导致非法访问的线程,将抛出以下堆栈
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1385)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1373)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1226)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:96)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1089)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
Exception in thread “Thread-2 (activemq-netty-threads)” java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$1
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:96)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1089)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
无法加载[io.netty.ut.ClassNotFoundException: 非法访问:此Web应用程序实例已停止。
il.concurrent.DefaultPromise$1]。为了调试以及终止导致非法访问的线程,将抛出以下
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1375)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1226)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
… 7 more
Caused by: java.lang.IllegalStateException: 非法访问:此Web应用程序实例已停止。i栈跟踪。rent.DefaultPromise$1]。为了调试以及终止导致非法访问的线程,将抛出以下堆
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1385)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1373)
… 9 more
al-Jul-2020 10:36:09.862 信息 [Thread-4 (activemq-netty-threads)] org.apache.cat
ina.loader.WebappClassLoaderBase.checkStateForResourceLoading 非法访问:此Web应
。无法加载[io.netty.util.concurrent.DefaultPromise$1]。为了调试以及终止导致非法
的线程,将抛出以下堆栈跟踪。
加载[io.netty.util.cteException: 非法访问:此Web应用程序实例已停止。无法
oncurrent.DefaultPromise$1]。为了调试以及终止导致非法访问的线程,将抛出以下堆栈
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1385)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1373)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1226)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:96)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1089)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
Exception in thread “Thread-4 (activemq-netty-threads)” java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$1
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:96)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1089)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
al-Jul-2020 10:36:09.863 信息 [Thread-3 (activemq-netty-threads)] org.apache.cat
ina.loader.WebappClassLoaderBase.checkStateForResourceLoading 非法访问:此Web应
。无法加载[io.netty.util.concurrent.DefaultPromise$1]。为了调试以及终止导致非法
加载[io.netty.util.cteException: 非法访问:此Web应用程序实例已停止。无法
oncurrent.DefaultPromise$1]。为了调试以及终止导致非法访问的线程,将抛出以下堆栈
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1385)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1373)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1226)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:96)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1089)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
Exception in thread “Thread-3 (activemq-netty-threads)” java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$1
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:96)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1089)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
al-Jul-2020 10:36:09.864 信息 [Thread-1 (activemq-netty-threads)] org.apache.cat
ina.loader.WebappClassLoaderBase.checkStateForResourceLoading 非法访问:此Web应
。无法加载[io.netty.util.concurrent.DefaultPromise$1]。为了调试以及终止导致非法
加载[io.netty.util.cteException: 非法访问:此Web应用程序实例已停止。无法
oncurrent.DefaultPromise$1]。为了调试以及终止导致非法访问的线程,将抛出以下堆栈
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1385)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1373)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1226)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:96)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1089)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
Exception in thread “Thread-1 (activemq-netty-threads)” java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$1
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:96)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1089)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
Exception in thread “Thread-0 (activemq-netty-threads)” java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$1
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:498)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:96)
at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1089)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(A

Thank you all.

It was something as simple as the name of the database indicated for the extension using sudo -u postgres psql -c “create extension postgis;” dhis2 during installation being different from the actual database name

Thanks