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.
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)
âŠ
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.
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)
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âŠ
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âŠ