Error: Failed to load class "org.slf4j.impl.StaticLoggerBinder"

Hi.
I have problem with this Exception:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
maj 01, 2017 9:47:39 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.haulmont.cuba.core.sys.AppContextLoader
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path   resource [cuba-spring.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: org.slf4j.helpers.NOPLogger cannot be cast to ch.qos.logback.classic.Logger

I tried this solution: http://www.slf4j.org/codes.html#StaticLoggerBinder but that did not help.

I don’t have any dependencies.

Marcin

Hi Marcin,

Does it take place in standard deployment to Tomcat done by Studio?

Hi Konstantin,

Yes, in standard deployment.

I found reason: I added dependency: mybatis-freemarker and this exception appeared.
I removed this dependency , run clean task, and remove all build directories and deploy directory, gradle cache but it did not help.

Only one solution what I found, is created a new project and copy sources from prev project.

For mybatis-freemarker I must have this in build.gradle file:


        compile('org.mybatis.scripting:mybatis-freemarker:1.1.1') {
            exclude(group: 'org.slf4j', module: 'slf4j-log4j12')
            exclude(group:'org.mybatis',module:'mybatis-spring')
            exclude(group:'org.freemarker',module:'freemarker')
        }

I don’t know why dependencies destroyed project even when they are removed?

Marcin
p.s. Sorry for my bad english.

> don’t know why dependencies destroyed project even when they are removed?

That’s very strange. Either Tomcat contained the jars or build.gradle had the dependency and brought the jars again. If you still have that broken project, please take a look into tomcat/shared/lib folder and into build.gradle.

Thanks.

Hi
I have similar problem in my project but didn’t see anything related to mybatis in the build.gradle. I tried to fix it using the code that Marcin used but no luck. Here is the exception -


INFO: No Spring WebApplicationInitializer types detected on classpath
May 04, 2017 9:47:01 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.haulmont.cuba.core.sys.AppContextLoader
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [cuba-spring.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: org.slf4j.helpers.NOPLogger cannot be cast to ch.qos.logback.classic.Logger
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
        at com.haulmont.cuba.core.sys.CubaClassPathXmlApplicationContext.<init>(CubaClassPathXmlApplicationContext.java:27)
        at com.haulmont.cuba.core.sys.CubaCoreApplicationContext.<init>(CubaCoreApplicationContext.java:26)
        at com.haulmont.cuba.core.sys.AppContextLoader.createApplicationContext(AppContextLoader.java:90)
        at com.haulmont.cuba.core.sys.AppContextLoader.createApplicationContext(AppContextLoader.java:36)
        at com.haulmont.cuba.core.sys.AbstractAppContextLoader.initAppContext(AbstractAppContextLoader.java:56)
        at com.haulmont.cuba.core.sys.AbstractWebAppContextLoader.contextInitialized(AbstractWebAppContextLoader.java:73)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: org.slf4j.helpers.NOPLogger cannot be cast to ch.qos.logback.classic.Logger
        at com.haulmont.cuba.core.sys.logging.EclipseLinkLog.getLog(EclipseLinkLog.java:54)
        at com.haulmont.cuba.core.sys.logging.EclipseLinkLog.shouldLog(EclipseLinkLog.java:96)
        at org.eclipse.persistence.internal.sessions.AbstractSession.shouldLog(AbstractSession.java:4566)
        at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4742)
        at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4716)
        at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4692)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2027)
        at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:347)
        at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:313)
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579)
        ... 30 more

May 04, 2017 9:47:01 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
May 04, 2017 9:47:01 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/myApplication-core] startup failed due to previous errors
May 04, 2017 9:47:01 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Studio Projects\ems\myproject\build\tomcat\webapps\myApplication-core has finished in 15,860 ms

Hi.

Do you have any foreign dependencies in build.gradle?

only Vaadin Overlay addon.