Sl4j error when using msal4j needed for ActiveDirectoryPassword DB authentication

Hi,

we need to use msal4j for connection to Azure SQL DB.
msal4j needs sl4j.
But when I use that,
Cuba app does not work any more.
Using the 7.2.20 Cuba version.

Any idea, how to solve that?

Here the implementations I need for msal4j:

   implementation 'com.microsoft.sqlserver:mssql-jdbc:11.2.0.jre11'
    implementation 'net.minidev:accessors-smart:2.4.7'
    implementation 'org.ow2.asm:asm:9.1'
    implementation 'com.nimbusds:content-type:2.1'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.12.1'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.12.1'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.1'
    implementation 'com.github.stephenc.jcip:jcip-annotations:1.0-1'
    implementation 'net.minidev:json-smart:2.4.7'
    implementation 'com.nimbusds:lang-tag:1.5'
    implementation 'com.microsoft.azure:msal4j:1.11.0'
    implementation 'com.nimbusds:nimbus-jose-jwt:9.9.3'
    implementation 'com.nimbusds:oauth2-oidc-sdk:9.7'

Tomcat is starting without an error,
but when I call the app URL,
I get this error:

com.haulmont.cuba.web.sys.remoting.LocalServiceAccessException: Unable to connect to middleware. Middleware block ‘app-core’ failed to start. See exception cause for details.
at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.createServiceAccessException(LocalServiceProxy.java:193)
at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.invoke(LocalServiceProxy.java:108)
at com.sun.proxy.$Proxy29.healthCheck(Unknown Source)
at com.haulmont.cuba.web.AppUI.init(AppUI.java:342)
at com.vaadin.ui.UI.doInit(UI.java:771)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:209)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:67)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1636)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:465)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74)
at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘methodValidationPostProcessor’ defined in class path resource [com/haulmont/cuba/spring.xml]: Cannot resolve reference to bean ‘cuba_BeanValidation’ while setting bean property ‘beanValidation’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_BeanValidation’: Unsatisfied dependency expressed through field ‘messages’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_Messages’: 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’: Unsatisfied dependency expressed through field ‘tools’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_MetadataTools’: Unsatisfied dependency expressed through field ‘dynamicAttributesTools’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_DynamicAttributesTools’: Unsatisfied dependency expressed through field ‘dynamicAttributes’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_DynamicAttributesService’: Unsatisfied dependency expressed through field ‘dynamicAttributesManagerAPI’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_DynamicAttributesManager’: Unsatisfied dependency expressed through field ‘persistence’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_Persistence’: Unsatisfied dependency expressed through field ‘transactions’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_Transactions’: Unsatisfied dependency expressed through field ‘transactionManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘transactionManager’ defined in class path resource [com/haulmont/cuba/spring.xml]: Cannot resolve reference to bean ‘entityManagerFactory’ while setting bean property ‘entityManagerFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [com/haulmont/cuba/spring.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: class org.slf4j.helpers.NOPLogger cannot be cast to class ch.qos.logback.classic.Logger (org.slf4j.helpers.NOPLogger is in unnamed module of loader java.net.URLClassLoader @31c88ec8; ch.qos.logback.classic.Logger is in unnamed module of loader java.net.URLClassLoader @1cbbffcd)



and in addition the dependencies tree for app-core (looks similar in app-global and app-web)
I just copied some parts to show 


Project :app-core
compile - Dependencies for source set ‘main’ (deprecated, use ‘implementation’ instead).
±-- project :app-global
| ±-- com.haulmont.cuba:cuba-global:7.2.20
| | ±-- org.codehaus.groovy:groovy:2.5.14
| | ±-- org.codehaus.groovy:groovy-templates:2.5.14
| | | ±-- org.codehaus.groovy:groovy:2.5.14
| | | -– org.codehaus.groovy:groovy-xml:2.5.14
| | | -– org.codehaus.groovy:groovy:2.5.14
| | ±-- org.codehaus.groovy:groovy-sql:2.5.14
| | | -– org.codehaus.groovy:groovy:2.5.14
| | ±-- org.apache.commons:commons-lang3:3.9 → 3.12.0
| | ±-- org.apache.commons:commons-collections4:4.4
| | ±-- org.apache.commons:commons-text:1.10.0
| | | -– org.apache.commons:commons-lang3:3.12.0
| | ±-- commons-io:commons-io:2.6
| | ±-- commons-cli:commons-cli:1.4
| | ±-- commons-codec:commons-codec:1.13
| | ±-- org.apache.httpcomponents:httpclient:4.5.10
| | | ±-- org.apache.httpcomponents:httpcore:4.4.12
| | | ±-- commons-logging:commons-logging:1.2
| | | -– commons-codec:commons-codec:1.11 → 1.13
| | ±-- org.apache.commons:commons-pool2:2.7.0
| | ±-- org.apache.commons:commons-compress:1.21
| | ±-- org.dom4j:dom4j:2.1.3
| | ±-- xml-apis:xml-apis:1.4.01
| | ±-- javax.activation:activation:1.1.1
| | ±-- com.sun.mail:javax.mail:1.6.2
| | | -– javax.activation:activation:1.1 → 1.1.1
| | ±-- ch.qos.logback:logback-classic:1.2.3
| | | ±-- ch.qos.logback:logback-core:1.2.3
| | | -– org.slf4j:slf4j-api:1.7.25 → 1.7.36
| | ±-- org.slf4j:log4j-over-slf4j:1.7.29
| | | -– org.slf4j:slf4j-api:1.7.29 → 1.7.36
| | ±-- org.perf4j:perf4j:0.9.16


| | -– javax.annotation:javax.annotation-api:1.3.2
| ±-- com.microsoft.sqlserver:mssql-jdbc:11.2.0.jre11
| | -– com.microsoft.azure:msal4j:1.13.0
| | ±-- com.nimbusds:oauth2-oidc-sdk:9.35
| | | ±-- com.github.stephenc.jcip:jcip-annotations:1.0-1
| | | ±-- com.nimbusds:content-type:2.2
| | | ±-- net.minidev:json-smart:[1.3.3,2.4.8] → 2.4.8
| | | | -– net.minidev:accessors-smart:2.4.8
| | | | -– org.ow2.asm:asm:9.1
| | | ±-- com.nimbusds:lang-tag:1.6
| | | -– com.nimbusds:nimbus-jose-jwt:9.22
| | | -– com.github.stephenc.jcip:jcip-annotations:1.0-1
| | ±-- net.minidev:json-smart:2.4.8 ()
| | ±-- org.slf4j:slf4j-api:1.7.36
| | -– com.fasterxml.jackson.core:jackson-databind:2.13.2.1
| | ±-- com.fasterxml.jackson.core:jackson-annotations:2.13.2
| | -– com.fasterxml.jackson.core:jackson-core:2.13.2
| ±-- net.minidev:accessors-smart:2.4.7 → 2.4.8 (
)
| ±-- org.ow2.asm:asm:9.1
| ±-- com.nimbusds:content-type:2.1 → 2.2
| ±-- com.fasterxml.jackson.core:jackson-annotations:2.12.1 → 2.13.2
| ±-- com.fasterxml.jackson.core:jackson-core:2.12.1 → 2.13.2
| ±-- com.fasterxml.jackson.core:jackson-databind:2.12.1 → 2.13.2.1 ()
| ±-- com.github.stephenc.jcip:jcip-annotations:1.0-1
| ±-- net.minidev:json-smart:2.4.7 → 2.4.8 (
)
| ±-- com.nimbusds:lang-tag:1.5 → 1.6
| ±-- com.microsoft.azure:msal4j:1.11.0 → 1.13.0 ()
| ±-- com.nimbusds:nimbus-jose-jwt:9.9.3 → 9.22 (
)
| ±-- com.nimbusds:oauth2-oidc-sdk:9.7 → 9.35 ()
| ±-- javax.xml.bind:jaxb-api:2.3.1
| | -– javax.activation:javax.activation-api:1.2.0
| -– org.glassfish.jaxb:jaxb-runtime:2.3.1
| ±-- javax.xml.bind:jaxb-api:2.3.1 (
)
| ±-- org.glassfish.jaxb:txw2:2.3.1
| ±-- com.sun.istack:istack-commons-runtime:3.0.7
| ±-- org.jvnet.staxex:stax-ex:1.8
| ±-- com.sun.xml.fastinfoset:FastInfoset:1.2.15
| -– javax.activation:javax.activation-api:1.2.0
-– com.haulmont.cuba:cuba-core:7.2.20
±-- com.haulmont.cuba:cuba-global:7.2.20 ()
±-- com.haulmont.cuba:cuba-shared-lib:7.2.20
| ±-- ch.qos.logback:logback-classic:1.2.3 (
)
| -– org.slf4j:log4j-over-slf4j:1.7.29 (*)
±-- com.thoughtworks.xstream:xstream:1.4.17
| -– io.github.x-stream:mxparser:1.2.1
| -– xmlpull:xmlpull:1.1.3.1

| | ±-- ch.qos.logback:logback-classic:1.2.3
| | | ±-- ch.qos.logback:logback-core:1.2.3
| | | -– org.slf4j:slf4j-api:1.7.25 → 1.7.36
| | ±-- org.slf4j:log4j-over-slf4j:1.7.29
| | | -– org.slf4j:slf4j-api:1.7.29 → 1.7.36

| ±-- com.haulmont.cuba:cuba-shared-lib:7.2.20
| | ±-- ch.qos.logback:logback-classic:1.2.3 ()
| | -– org.slf4j:log4j-over-slf4j:1.7.29 (
)
| ±-- com.thoughtworks.xstream:xstream:1.4.17
| | -– io.github.x-stream:mxparser:1.2.1
| | -– xmlpull:xmlpull:1.1.3.1
| ±-- org.jgroups:jgroups:4.1.8.Final

| -– com.zaxxer:HikariCP:3.4.1
| -– org.slf4j:slf4j-api:1.7.25 → 1.7.36

±-- javax.servlet:javax.servlet-api:3.1.0
±-- com.microsoft.sqlserver:mssql-jdbc:11.2.0.jre11
| -– com.microsoft.azure:msal4j:1.13.0
| ±-- com.nimbusds:oauth2-oidc-sdk:9.35
| | ±-- com.github.stephenc.jcip:jcip-annotations:1.0-1
| | ±-- com.nimbusds:content-type:2.2
| | ±-- net.minidev:json-smart:[1.3.3,2.4.8] → 2.4.8
| | | -– net.minidev:accessors-smart:2.4.8
| | | -– org.ow2.asm:asm:9.1
| | ±-- com.nimbusds:lang-tag:1.6
| | -– com.nimbusds:nimbus-jose-jwt:9.22
| | -– com.github.stephenc.jcip:jcip-annotations:1.0-1
| ±-- net.minidev:json-smart:2.4.8 (*)
| ±-- org.slf4j:slf4j-api:1.7.36
| -– com.fasterxml.jackson.core:jackson-databind:2.13.2.1
| ±-- com.fasterxml.jackson.core:jackson-annotations:2.13.2
| -– com.fasterxml.jackson.core:jackson-core:2.13.2

| | ±-- ch.qos.logback:logback-classic:1.2.3
| | | ±-- ch.qos.logback:logback-core:1.2.3
| | | -– org.slf4j:slf4j-api:1.7.25 → 1.7.36
| | ±-- org.slf4j:log4j-over-slf4j:1.7.29
| | | -– org.slf4j:slf4j-api:1.7.29 → 1.7.36

| ±-- com.microsoft.sqlserver:mssql-jdbc:11.2.0.jre11
| | -– com.microsoft.azure:msal4j:1.13.0
| | ±-- com.nimbusds:oauth2-oidc-sdk:9.35
| | | ±-- com.github.stephenc.jcip:jcip-annotations:1.0-1
| | | ±-- com.nimbusds:content-type:2.2
| | | ±-- net.minidev:json-smart:[1.3.3,2.4.8] → 2.4.8
| | | | -– net.minidev:accessors-smart:2.4.8
| | | | -– org.ow2.asm:asm:9.1
| | | ±-- com.nimbusds:lang-tag:1.6
| | | -– com.nimbusds:nimbus-jose-jwt:9.22
| | | -– com.github.stephenc.jcip:jcip-annotations:1.0-1
| | ±-- net.minidev:json-smart:2.4.8 (*)
| | ±-- org.slf4j:slf4j-api:1.7.36
| | -– com.fasterxml.jackson.core:jackson-databind:2.13.2.1
| | ±-- com.fasterxml.jackson.core:jackson-annotations:2.13.2
| | -– com.fasterxml.jackson.core:jackson-core:2.13.2

±-- com.haulmont.cuba:cuba-core:7.2.20
| ±-- com.haulmont.cuba:cuba-global:7.2.20 ()
| ±-- com.haulmont.cuba:cuba-shared-lib:7.2.20
| | ±-- ch.qos.logback:logback-classic:1.2.3 (
)
| | -– org.slf4j:log4j-over-slf4j:1.7.29 (*)
| ±-- com.thoughtworks.xstream:xstream:1.4.17
| | -– io.github.x-stream:mxparser:1.2.1
| | -– xmlpull:xmlpull:1.1.3.1
| ±-- org.jsoup:jsoup:1.12.1
| -– com.zaxxer:HikariCP:3.4.1
| -– org.slf4j:slf4j-api:1.7.25 → 1.7.36

-– com.microsoft.sqlserver:mssql-jdbc:11.2.0.jre8
-– com.microsoft.azure:msal4j:1.13.0
±-- com.nimbusds:oauth2-oidc-sdk:9.35
| ±-- com.github.stephenc.jcip:jcip-annotations:1.0-1
| ±-- com.nimbusds:content-type:2.2
| ±-- net.minidev:json-smart:[1.3.3,2.4.8] → 2.4.8
| | -– net.minidev:accessors-smart:2.4.8
| | -– org.ow2.asm:asm:9.1
| ±-- com.nimbusds:lang-tag:1.6
| -– com.nimbusds:nimbus-jose-jwt:9.22
| -– com.github.stephenc.jcip:jcip-annotations:1.0-1
±-- net.minidev:json-smart:2.4.8 (*)
±-- org.slf4j:slf4j-api:1.7.36
-– com.fasterxml.jackson.core:jackson-databind:2.13.2.1
±-- com.fasterxml.jackson.core:jackson-annotations:2.13.2
-– com.fasterxml.jackson.core:jackson-core:2.13.2
| ±-- com.haulmont.cuba:cuba-global:7.2.20
| | ±-- org.codehaus.groovy:groovy:2.5.14
| | ±-- org.codehaus.groovy:groovy-templates:2.5.14
| | | ±-- org.codehaus.groovy:groovy:2.5.14
| | | -– org.codehaus.groovy:groovy-xml:2.5.14
| | | -– org.codehaus.groovy:groovy:2.5.14
| | ±-- org.codehaus.groovy:groovy-sql:2.5.14
| | | -– org.codehaus.groovy:groovy:2.5.14
| | ±-- org.apache.commons:commons-lang3:3.9 → 3.12.0
| | ±-- org.apache.commons:commons-collections4:4.4
| | ±-- org.apache.commons:commons-text:1.10.0
| | | -– org.apache.commons:commons-lang3:3.12.0
| | ±-- commons-io:commons-io:2.6
| | ±-- commons-cli:commons-cli:1.4
| | ±-- commons-codec:commons-codec:1.13
| | ±-- org.apache.httpcomponents:httpclient:4.5.10
| | | ±-- org.apache.httpcomponents:httpcore:4.4.12
| | | ±-- commons-logging:commons-logging:1.2
| | | -– commons-codec:commons-codec:1.11 → 1.13
| | ±-- org.apache.commons:commons-pool2:2.7.0
| | ±-- org.apache.commons:commons-compress:1.21
| | ±-- org.dom4j:dom4j:2.1.3
| | ±-- xml-apis:xml-apis:1.4.01
| | ±-- javax.activation:activation:1.1.1
| | ±-- com.sun.mail:javax.mail:1.6.2
| | | -– javax.activation:activation:1.1 → 1.1.1
| | ±-- ch.qos.logback:logback-classic:1.2.3
| | | ±-- ch.qos.logback:logback-core:1.2.3
| | | -– org.slf4j:slf4j-api:1.7.25 → 1.7.36
| | ±-- org.slf4j:log4j-over-slf4j:1.7.29
| | | -– org.slf4j:slf4j-api:1.7.29 → 1.7.36
| | ±-- org.perf4j:perf4j:0.9.16

after trying multiple settings and versions,
I am ending with msal4j 11.1.0
jdk 11
mssqljdbc 9.4.1 jre11

I can exclude implementation (‘com.microsoft.azure:msal4j:1.11.0’) { exclude (group: ‘org.slf4j’, module: ‘slf4j-api’) }
but then I get the error:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

when I put any slf4j jar into the Tomcat lib dir, I get the error:
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See SLF4J Error Codes for further details.
SLF4J: Failed to load class “org.slf4j.impl.StaticMDCBinder”.
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See SLF4J Error Codes for further details.

And if I delete the sl4j jar from the lib dir,
I get the error NoClassDefFound


do not know what else I could test.
This issue only pops up in Cuba app together with Tomcat.

btw
 it works with JMIX, but we cannot migrate all Cuba apps, because the effort would be to big


Did you try to put both API and implementation jars as pointed out in the SLF4J docs, like

slf4j-api-2.0.7.jar
slf4j-simple-2.0.7.jar

Hi,
tried it now
 but did not solve the issue.
When I put the jars only in the lib,
starting the app from the studio will automatically create an older version of the slf4j-api in the shared/lib folder

When I put both mentioned jars into the lib folder
 I got much more info logs, but also an error in the end.

When I only put the slf4j-api-2.0.7.jar into the shared/lib I get this error:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See SLF4J Error Codes for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J: Ignoring binding found at [jar:file:/D:/Daten/Cuba/active_projects/untitled3/deploy/tomcat/shared/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See SLF4J Error Codes for an explanation.

When I put it also into the lib folder, I get this:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See SLF4J Error Codes for further details.

when I put both into the lib folder, I get this error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘methodValidationPostProcessor’ defined in class path resource [com/haulmont/cuba/spring.xml]: Cannot resolve reference to bean ‘cuba_BeanValidation’ while setting bean property ‘beanValidation’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_BeanValidation’: Unsatisfied dependency expressed through field ‘messages’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_Messages’: 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’: Unsatisfied dependency expressed through field ‘tools’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_MetadataTools’: Unsatisfied dependency expressed through field ‘dynamicAttributesTools’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_DynamicAttributesTools’: Unsatisfied dependency expressed through field ‘dynamicAttributes’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_DynamicAttributesService’: Unsatisfied dependency expressed through field ‘dynamicAttributesManagerAPI’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_DynamicAttributesManager’: Unsatisfied dependency expressed through field ‘persistence’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_Persistence’: Unsatisfied dependency expressed through field ‘transactions’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_Transactions’: Unsatisfied dependency expressed through field ‘transactionManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘transactionManager’ defined in class path resource [com/haulmont/cuba/spring.xml]: Cannot resolve reference to bean ‘entityManagerFactory’ while setting bean property ‘entityManagerFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [com/haulmont/cuba/spring.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: class org.slf4j.simple.SimpleLogger cannot be cast to class ch.qos.logback.classic.Logger (org.slf4j.simple.SimpleLogger is in unnamed module of loader java.net.URLClassLoader @39529185; ch.qos.logback.classic.Logger is in unnamed module of loader java.net.URLClassLoader @72f926e6)


Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_BeanValidation’: Unsatisfied dependency expressed through field ‘messages’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_Messages’: 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’: Unsatisfied dependency expressed through field ‘tools’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_MetadataTools’: Unsatisfied dependency expressed through field ‘dynamicAttributesTools’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_DynamicAttributesTools’: Unsatisfied dependency expressed through field ‘dynamicAttributes’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_DynamicAttributesService’: Unsatisfied dependency expressed through field ‘dynamicAttributesManagerAPI’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_DynamicAttributesManager’: Unsatisfied dependency expressed through field ‘persistence’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_Persistence’: Unsatisfied dependency expressed through field ‘transactions’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘cuba_Transactions’: Unsatisfied dependency expressed through field ‘transactionManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘transactionManager’ defined in class path resource [com/haulmont/cuba/spring.xml]: Cannot resolve reference to bean ‘entityManagerFactory’ while setting bean property ‘entityManagerFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [com/haulmont/cuba/spring.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: class org.slf4j.simple.SimpleLogger cannot be cast to class ch.qos.logback.classic.Logger (org.slf4j.simple.SimpleLogger is in unnamed module of loader java.net.URLClassLoader @39529185; ch.qos.logback.classic.Logger is in unnamed module of loader java.net.URLClassLoader @72f926e6)

I really want to help, but I’m unable to reliably model your situation. Please provide a project where we could reproduce the problem.

Hi Konstantin,

thx a lot!
I zipped the project.
It uses postgresql for main db
and an additional datastore to connect to Azure SQL DB with authentication=activedirectorypassword

In our environment,
the implemented .jar files are the only way to get the JDBC connection working fine to the Azure SQL.
It works outside Cuba and also in Cuba when i.e. testing the connection or generating the model.

Only at runtime (started via Cuba studio or with startup.bat) I have those issues.
I am working on Windows 11, tested different Java versions, from Oracle 8 to openJDK 11


Kind regards
Roland

untitled3.zip (94.2 KB)

Find a solution:

Put the logback-classic-1.2.3.jar, logback-core-1.2.3.jar, slf4j-api-1.7.32.jar
into the lib folder
and excluded the slf4j in the msal4j implementation


Now I have a huge logging (must be set to debug somewhere)
but it works fine now


Regards
Roland

1 Like

logback.xml in tomcat/lib folder
configuration>
appender name=“STDOUT” class=“ch.qos.logback.core.ConsoleAppender”>
encoder>
pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
/encoder>
/appender>

root level=“info”>
appender-ref ref=“STDOUT” />
/root>
/configuration>