Java Error stopping DHIS2 startup

Dear all,
I tried to back up and restore my instance which is running on the 2.31.9 war file. The following is the information about the installation:
Server version: Apache Tomcat/8.5.39 (Ubuntu)
Server built: Sep 9 2019 19:47:51 UTC
Server number: 8.5.39.0
OS Name: Linux
OS Version: 4.15.0-145-generic
Architecture: amd64
Java Home: /usr/lib/jvm/java-11-openjdk-amd64
JVM Version: 11.0.11+9-Ubuntu-0ubuntu2.18.04
JVM Vendor: Ubuntu
CATALINA_BASE: /home/hmis/tomcat-hmis
CATALINA_HOME: /usr/share/tomcat8

The error in the log file is:

ERROR 2021-09-02 15:56:04,385 Context initialization failed (ContextLoader.java [localhost-startStop-1])
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘transactionManager’ defined in URL [jar:file:/home/hmis/tomcat-hmis/webapps/ROOT/WEB-INF/lib/dhis-support-hibernate-2.31.9.jar!/META-INF/dhis/beans.xml]: Cannot resolve reference to bean ‘sessionFactory’ while setting bean property ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘flyway’ defined in URL [jar:file:/home/hmis/tomcat-hmis/webapps/ROOT/WEB-INF/lib/dhis-support-db-migration-2.31.9.jar!/META-INF/dhis/beans.xml]: Cannot resolve reference to bean ‘flywayConfig’ while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘databaseInfoProvider’: Unsatisfied dependency expressed through field ‘jdbcTemplate’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jdbcTemplate’ defined in URL [jar:file:/home/hmis/tomcat-hmis/webapps/ROOT/WEB-INF/lib/dhis-support-hibernate-2.31.9.jar!/META-INF/dhis/beans.xml]: Cannot resolve reference to bean ‘dataSource’ while setting bean property ‘dataSource’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource’ defined in URL [jar:file:/home/hmis/tomcat-hmis/webapps/ROOT/WEB-INF/lib/dhis-support-hibernate-2.31.9.jar!/META-INF/dhis/beans.xml]: Cannot resolve reference to bean ‘driverClass’ while setting bean property ‘driverClass’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘driverClass’ defined in URL [jar:file:/home/hmis/tomcat-hmis/webapps/ROOT/WEB-INF/lib/dhis-support-hibernate-2.31.9.jar!/META-INF/dhis/beans.xml]: Cannot resolve reference to bean ‘hibernateConfigurationProvider’ while setting bean property ‘hibernateConfigurationProvider’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘hibernateConfigurationProvider’: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Dear all,
I always noticed this message when I stopped the instance:
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED

In with that message i found out that i have 2 java (Java-8 and Java-11). the 2.31.9 war seem to be working well with java-8 and 2.34.7 war seem to be working well with java-11. All i did was the specify JAVA_OPTS path and start the instance. The JAVA_OPTS path is define in the setenv.sh file.

2 Likes

:star2: @Gerald_Thomas :star2: thank you for sharing the problem and its solution! :grin::+1:

1 Like