`

解决Failed to load class "org.slf4j.impl.StaticLoggerBinder"

    博客分类:
  • SSH
阅读更多
下载了hibernate-distribution-3.3.1.GA-dist集成到web工程中,运行tomcat服务器,其中报错:
Failed to load class "org.slf4j.impl.StaticLoggerBinder".
详细信息如下:

===========================================================================>
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2010-11-15 22:41:38 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.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [D:\MyEclipseWorkspace\misse\WebRoot\WEB-INF\classes\com\liany\misse\misse-spring-global.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
... 31 more
Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.class$(LocalSessionFactoryBean.java:158)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.<init>(LocalSessionFactoryBean.java:158)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
... 33 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 44 more

================================================================================
hibernate工程里面使用的是hibernate3.3.1的Lib。
提示信息中多次提到SLF4J,google了一下,才发现这是现在的Hibernate使用SLF4J API记录日志,所以在Hibernate的lib中,不再提供Log4J的包,而大部分框架依然使用Log4J记录日志,这样导致了兼容性问题。
     解决办法,两步:

        一、在编译路径中添加Log4J的包,比如我一直在用的log4j-1.2.8.jar;

        二、再添加一个叫做slf4j-log4j12-1.5.11.jar的包进行转换,注意到这里的log4j12,可能对应的是log4j 1.2版本。

补充:
SLF4J官方下载:http://www.slf4j.org/download.html
下载对应版本后加压找到slf4j-log4j12-XX.jar即可


解决!
解决方法出处来自:http://zhoujingxian.iteye.com/blog/657079
感谢zjx2388!
1
4
分享到:
评论

相关推荐

    解决SLF4J: Failed to load class "org.slf

    总之,解决"SLF4J: Failed to load class "org.slf"错误的关键在于正确配置和管理项目的依赖,确保SLF4J能找到并使用一个有效的日志实现。通过上述步骤,你应该能够成功解决这个问题,并确保日志功能正常工作。

    hibernate的slf4j-nop包

    hibernate的错误SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".的解决方法是:下载slf4j-nop.jar、slf4f-simple.jar、slf4j-log4j12.jar、slf4j-jdk14.jar或logback-classic.jar中某一个而且...

    slf4j-log4j

    用于Failed to load class "org.slf4j.impl.StaticLoggerBinder"问题的jar包

    slf4j-log4j12-1.7.5.jar

    解决Failed to load class "org.slf4j.impl.StaticLoggerBinder" 所需要的jar包:slf4j-log4j12-1.7.5.jar

    slf4j-nop-1.6.6.jar

    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...

    tomcat9-slf4j-logback:Tomcat 9.0.x的SLF4J和Logback集成

    Tomcat + SLF4J +登录 Tomcat SLF4J Logback是tomcat的替代产品,它允许所有内部日志记录全部使用我们喜欢的slf4j / logback库。 注意 从logback 1.1.7开始,不再需要在server.xml中包含${catalina.home}来进行...

    slf4j-nop-1.6.1.jar文件.rar

    当你遇到“SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder”这样的错误时,通常意味着你的应用程序在运行时未能找到合适的SLF4J实现。StaticLoggerBinder是SLF4J用来绑定具体日志框架的关键类,...

    gradle-javadoc-notimestamp-error:带有-doctitle,-notimestamp和自定义doclet的Gradle 6.0 javadoc任务错误的公共再现

    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#StaticLoggerBind

    TestingApp:用于测试实践的测试应用纲要

    运行.jar文件例如java -jar compendium-of-test-apps-v1-1.jar 服务器应该会启动,您会看到如下内容: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".SLF4J: Defaulting to no-operation (NOP)...

    配置hibernate-distribution-3.6.6.Final时出现的问题及解决办法

    - **具体表现**:在日志输出时,可能会看到类似“Failed to load class 'org.slf4j.impl.StaticLoggerBinder'”的警告信息。 - **原因分析**:这表明SLF4J(Simple Logging Facade for Java)未能找到一个合适的日志...

    使用Hibernate一些常见错误解决办法

    如果系统报错`Failed to load class org.slf4j.impl.StaticLoggerBinder`,这意味着没有找到合适的SLF4J绑定。SLF4J(Simple Logging Facade for Java)是一个日志门面,需要与特定的日志实现(如log4j、logback)...

    Hadoop之hive安装

    例如,SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"。这种错误是因为没有找到合适的绑定SLF4J,无法载入到内存。解决的办法是下载新的合适的slf4j-nop.jar。 基本操作练习 在解决完错误后,...

    ActivitiDemo_LFP_HelloWorld实现

    1. &lt;span Failed to load class "org.slf4j.impl.StaticLoggerBinder". 2. SLF4J: Defaulting to no-operation (NOP) logger implementation 3. SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder ...

Global site tag (gtag.js) - Google Analytics