ED2 KC- Unsatisfied Dependency Exception: Error creating bean ...


Background

This is a database-level issue wherein a snapshot was deployed with migrations that were not included in the next official release.

This should not happen in our production instances because we do not typically deploy snapshot instances to production.

If this happens in a production instance - alert the Customer success team immediately.

Resolution

Do not undertake any actions without understanding the advice in this thread from the CoP:

https://community.dhis2.org/t/dhis2-patch-release-2-36-2-is-now-available-hot-fix/43525/9?u=chase.freeman

Also, Lars has mentioned to me flyway.migrate_out_of_order = true but consult him on the use of that config before using it.

Do not delete the flyway schema table without understanding the consequences.

Key Text

  • Context initialization failed (ContextLoader.java [main])
    org.springframework.beans.factory.UnsatisfiedDependencyException
  • If you removed this migration intentionally, run repair to mark the migration as deleted.

Example 1:

ERROR 2021-07-02T09:31:23,860 Context initialization failed (ContextLoader.java [main])
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘webMvcConfig’: Unsatisfied dependency expressed through field ‘userSettingService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.hisp.dhis.user.UserSettingService’ defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/dhis/WEB-INF/lib/dhis-service-core-2.36.2.jar!/org/hisp/dhis/user/DefaultUserSettingService.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.hisp.dhis.user.UserSettingStore’ defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/dhis/WEB-INF/lib/dhis-service-core-2.36.2.jar!/org/hisp/dhis/user/hibernate/HibernateUserSettingStore.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘flyway’ defined in class path resource [org/hisp/dhis/db/migration/config/FlywayConfig.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Validate failed:
Detected applied migration not resolved locally: 2.36.37. If you removed this migration intentionally, run repair to mark the migration as deleted.
Detected applied migration not resolved locally: 2.36.38. If you removed this migration intentionally, run repair to mark the migration as deleted.
Detected applied migration not resolved locally: 2.36.39. If you removed this migration intentionally, run repair to mark the migration as deleted.
Detected applied migration not resolved locally: 2.36.40. If you removed this migration intentionally, run repair to mark the migration as deleted.
Detected applied migration not resolved locally: 2.36.41. If you removed this migration intentionally, run repair to mark the migration as deleted.
Detected applied migration not resolved locally: 2.36.42. If you removed this migration intentionally, run repair to mark the migration as deleted.
Detected applied migration not resolved locally: 2.36.43. If you removed this migration intentionally, run repair to mark the migration as deleted.

Example 2:

29-Apr-2021 18:32:55.416 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
        org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcConfig': Unsatisfied dependency expressed through field 'userSettingService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.hisp.dhis.user.UserSettingService' defined in URL [jar:file:/var/lib/tomcat/webapps/ROOT/WEB-INF/lib/dhis-service-core-2.36.0.jar!/org/hisp/dhis/user/DefaultUserSettingService.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.hisp.dhis.user.UserSettingStore' defined in URL [jar:file:/var/lib/tomcat/webapps/ROOT/WEB-INF/lib/dhis-service-core-2.36.0.jar!/org/hisp/dhis/user/hibernate/HibernateUserSettingStore.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/hisp/dhis/db/migration/config/FlywayConfig.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Validate failed:
Detected applied migration not resolved locally: 2.36.37. If you removed this migration intentionally, run repair to mark the migration as deleted.
Detected applied migration not resolved locally: 2.36.38. If you removed this migration intentionally, run repair to mark the migration as deleted.
Detected applied migration not resolved locally: 2.36.39. If you removed this migration intentionally, run repair to mark the migration as deleted.