Cuba-Jmix migration: application start fails with UnsatisfiedDependencyException

Hello support team,

I migrated a Cuba application to Jmix using Jmix 1.5.1 and Studio 2022.3.3. I followed your [Migration from CUBA Platform :: Jmix Documentation]. After solving of all compile errors I tried to start the application, but get always an UnsatisfiedDependencyException. With debugger I found that creation of beans

  • cuba_Metadata
  • cuba_MessageTools
  • ui_AnonymousAuthenticationLocaleResolver
  • core_CurrentAuthentication
  • core_LogMdcFilterRegistrationBean

fails. I don’t know what to do anymore. Is this error still related to the migrated code?

The studio console output is:

2023-04-15 22:33:58.662  INFO 9748 --- [           main] de.vemango.marve.DiWaApplication         : Starting DiWaApplication using Java 11.0.16.1 on RolandRLE495 with PID 9748 (C:\p\DiWa\build\classes\java\main started by RolandR in C:\p\DiWa)
2023-04-15 22:33:58.671  INFO 9748 --- [           main] de.vemango.marve.DiWaApplication         : No active profile set, falling back to 1 default profile: "default"
2023-04-15 22:34:05.230  INFO 9748 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Jmix repositories in DEFAULT mode.
2023-04-15 22:34:05.625  INFO 9748 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 383 ms. Found 0 Jmix repository interfaces.
2023-04-15 22:34:06.277  INFO 9748 --- [           main] io.jmix.core.JmixModulesProcessor        : Using Jmix modules: [io.jmix.core, io.jmix.security, io.jmix.ui, io.jmix.securityui, io.jmix.data, io.jmix.audit, io.jmix.auditui, io.jmix.charts, io.jmix.dynattr, io.jmix.dynattrui, io.jmix.localfs, io.jmix.uidata, io.jmix.datatools, io.jmix.datatoolsui, io.jmix.eclipselink, io.jmix.securitydata, io.jmix.gridexportui, io.jmix.email, io.jmix.emailui, com.haulmont.cuba, io.jmix.dashboards, io.jmix.dashboardsui, io.jmix.dashboardschart, io.jmix.reports, io.jmix.reportsrest, io.jmix.reportsui, io.jmix.rest, io.jmix.securityoauth2, de.vemango.marve]
2023-04-15 22:34:06.284  INFO 9748 --- [           main] o.s.c.a.ConfigurationClassPostProcessor  : Cannot enhance @Configuration bean definition 'com.vaadin.spring.VaadinConfiguration' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2023-04-15 22:34:08.862  INFO 9748 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-04-15 22:34:08.883  INFO 9748 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-04-15 22:34:08.883  INFO 9748 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.73]
2023-04-15 22:34:09.033  INFO 9748 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-04-15 22:34:09.034  INFO 9748 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 9795 ms
2023-04-15 22:34:10.479  INFO 9748 --- [           main] i.j.c.i.s.JmixModulesClasspathScanner    : Classpath scan completed in 1259 ms
2023-04-15 22:34:11.756  WARN 9748 --- [           main] io.jmix.core.impl.MetaModelLoader        : Method EntityPropertyDifferenceModel.getLabel is not included in metadata because property audit_EntityPropertyDifferenceModel.label already exists
2023-04-15 22:34:37.987 ERROR 9748 --- [           main] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'core_LogMdcFilterRegistrationBean' defined in class path resource [io/jmix/core/CoreConfiguration.class]: Unsatisfied dependency expressed through method 'logMdcFilterFilterRegistrationBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'core_CurrentAuthentication': Unsatisfied dependency expressed through field 'localeResolvers'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ui_AnonymousAuthenticationLocaleResolver': Unsatisfied dependency expressed through field 'messageTools'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_MessageTools': Unsatisfied dependency expressed through field 'metadata'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_Metadata' defined in class path resource [com/haulmont/cuba/CubaConfiguration.class]: Unsatisfied dependency expressed through method 'metadata' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'core_MetadataLoader' defined in URL [jar:file:/C:/Users/rolandr.VEMANGO/.gradle/caches/modules-2/files-2.1/io.jmix.core/jmix-core/1.5.1/d05d147ab23f00fd0259c24bf538db23794eaabd/jmix-core-1.5.1.jar!/io/jmix/core/impl/MetadataLoader.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.jmix.core.impl.MetadataLoader]: Constructor threw exception; nested exception is java.lang.ClassCastException: class sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to class java.lang.Class (sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl and java.lang.Class are in module java.base of loader 'bootstrap')

Thanks in advance!
Roland

Hi,

I see some problems with one of your entity attributes:

Method EntityPropertyDifferenceModel.getLabel is not included in metadata because property audit_EntityPropertyDifferenceModel.label already exists

Also I see

Failed to instantiate [io.jmix.core.impl.MetadataLoader]: Constructor threw exception

Try putting the breakpoint in the MetadataLoader constructor. Maybe you’ll find what’s going on there.

Hello Maxim,
thanks for your hints!
EntityPropertyDifferenceModel is a class of io.jmix.audit.snapshot.model, so I assume it is correct.

Debugging of MetadataLoader construtor shows two problems in my entity definitions. They seems to be the result of more strict attribute checking of none persistent classes in Jmix (Object was possible as attribute type in Cuba). I modified these entities now.
But direct after constructor call of MetadataLoader the same Exception (BeanInstantiationException) will be raised…

Take a look at the BeanInstantiationException stracktrace. There must be an explanation about the cause and it must give you a hint where to look next.