一、错误信息

java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
at ch.qos.logback.ext.spring.LogbackConfigurer.initLogging(LogbackConfigurer.java:72)
at ch.qos.logback.ext.spring.web.WebLogbackConfigurer.initLogging(WebLogbackConfigurer.java:142)
at ch.qos.logback.ext.spring.web.LogbackConfigListener.contextInitialized(LogbackConfigListener.java:54)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

二、检查日志中是否包含如下信息

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/httx/run/tomcat/webapps/cashBillSite/WEB-INF/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/httx/run/tomcat/webapps/cashBillSite/WEB-INF/lib/logback-classic-1.0.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

三、问题原因

LogbackConfigurer在做初始化时,需要对返回LogggerContext做强转;在这里报错,报错原因是 slf4j-log4j12-1.6.4.jar和logback-classic-1.0.9.jar的有StaticLoggerBinder冲突,这里如果运气好,他加载的是logback-classic-1.0.9.jar的StaticLoggerBinder就不会报错,如果运气不好,加载slf4j-log4j12-1.6.4.jar中的StaticLoggerBinder就悲剧了,无法强转。

  slf4j-log4j12-1.6.4.jar和logback-classic-1.0.9.jar中StaticLoggerBinder路径一样,所以加载容易出错

四、解决方法

修改pom.xml文件,去掉对slf4j-log4j12-1.6.4.jar的引用

<dependency>
<groupId>tf56</groupId>
<artifactId>risk</artifactId>
<version>1.0.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

原文:http://www.cnblogs.com/simplelei/p/5408029.html

java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext问题原因及解决方法的更多相关文章

  1. org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext

    查看日志信息: SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/app/a ...

  2. org.slf4j.impl.Log4jLoggerAdapter cannot be cast to ch.qos.logback.classic.Logger

    https://stackoverflow.com/questions/31433246/classcastexception-org-slf4j-impl-log4jloggeradapter-ca ...

  3. spring boot启动STS 运行报错 java.lang.NoClassDefFoundError: ch/qos/logback/classic/LoggerContext

    spring boot启动STS 运行报错 java.lang.NoClassDefFoundError: ch/qos/logback/classic/LoggerContext 学习了: http ...

  4. java.lang.ClassCastException:weblogic.xml.jaxp.RegistryDocumentBuilderFactory cannot be cast to javax.xml.parsers.DocumentBuilderFactory

    java.lang.ClassCastException:weblogic.xml.jaxp.RegistryDocumentBuilderFactory cannot be cast to java ...

  5. Caused by: java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/i

    Caused by: java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/i ...

  6. java.lang.ClassCastException: com.sun.proxy.$Proxy53 cannot be cast to cn.service.impl.WorkinggServiceImpl

    java.lang.ClassCastException: com.sun.proxy.$Proxy53 cannot be cast to cn.service.impl.WorkinggServi ...

  7. java.lang.AbstractMethodError: org.slf4j.impl.JDK14LoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

    java.lang.AbstractMethodError: org.slf4j.impl.JDK14LoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/St ...

  8. java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.L(转)

    09-09 10:19:59.979: E/AndroidRuntime(2767): FATAL EXCEPTION: main09-09 10:19:59.979: E/AndroidRuntim ...

  9. java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot be cast to...异常

    异常: Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot ...

随机推荐

  1. String字符串类课后作业

    String动手动脑和课后作业 请运行以下示例代码StringPool.java,查看其输出结果.如何解释这样的输出结果?从中你能总结出什么? 结果: 总结:在Java中,内容相同的字串常量(&quo ...

  2. PHP文件的读取

    1.PHP部分文件操作函数 ( fopen ,fread ,filesize,fwrite,fclose ) 2.unlink()  rmdir() 删除函数 unlink(路径和文件名): rmdi ...

  3. recovery编译问题汇总

    1.修改支持USB大容量存储 (1).首先需要查看手机lun位置 手机链接电脑,打开cmd命令行,依次输入以下命令: adb shell find /sys -name "lun" ...

  4. 第一篇:Retrofit主要类UML图

    2016-05-06 16:07:09 1.先上一张Retrofit的代码结构图: 可以看到,Retrofit自身的结构很简单,代码量也不是很大.红色框部分是一些注解类,就是一些标记. 简单的看一下客 ...

  5. 为bootstrap添加更多自定义图标

    From: http://blog.csdn.net/mengxiangfeiyang/article/details/45224731 Twitter Bootstrap 真是前端开发的瑞士军刀,作 ...

  6. .net版高斯模糊算法

    最近挺多人找高斯算法,本人贴上一个高斯模糊算法类,希望可以帮助到大家.算法的效率还是可以接受的. #region 高斯模糊算法 /// <summary> /// 高斯模糊算法 /// & ...

  7. 硬件抽象层:HAL

    本节我们研究硬件抽象层:HALHAL,它是建立在Linux驱动之上的一套程序库.刚开始介绍了为什么要在Android中加入HAL,目的有三个,一,统一硬件的调用接口.二,解决了GPL版权问题.三,针对 ...

  8. what is service?

    SERVICE n.服务,服侍:服务业:维修服务:服役 vt.检修,维修:向…提供服务:保养:满足需要 adj.服务性的:耐用的:服现役的 更多详情:http://dict.baidu.com/s?w ...

  9. MFC 对话框控件自动布局

    MFC 设计界面程序总是不够智能,没有这样,没有那样. 今天为了加强mfc功能,设计了一个自动布局的类,使用非常简单. 原理: 每个控件都有一个矩形区域,矩形区域就是控件在对话框中的显示位置和大小, ...

  10. 张小龙微信小程序演讲内容简介

    1月9号,看看实际上如何