一、错误信息

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. Anjs分词器以及关键词抓取使用的方法

    首先介绍一下这个网址非常有用本文所有的关于Anjs起源来自这里请先查看一下 https://github.com/NLPchina/ansj_seg 在本次测试使用的是     import java ...

  2. LeetCode 177 Nth-Highest Salary mysql,取第n条数据,limit子句 难度:1

    https://leetcode.com/problems/nth-highest-salary/ ATTENTION:limit 子句只能接受int常量,不能接受运算式 CREATE FUNCTIO ...

  3. 也说析构---C++

    正如我们知道的: 通过new分配到heap中的对象,当对其delete,才会被析构: 分配在stack中的对象,当其离开作用域时被析构:

  4. 2014 NOIP 赛前自我整理提醒。

    空谈WA,实干AC. 所以作为一个就要上战场的OIer ,实干当然是最重要,但刷题不在多,要点牢记是关键,虽然本渣没记住多少,但还是列几点值得注意的小点. 1.战场上容不得失误. 对于每日都要敲键盘的 ...

  5. 《Pro Express.js》学习笔记——app.params中间件

    app.param中间件用于对URL中的参数进行获取.加工.输出,提供公有逻辑,以达到代码重构的目的. 以下示例采取三个步骤对代码进行重构,app.param中间件的作用非常明显: 不使用中间件 使用 ...

  6. gif显示

    public void gifplay(string path,ref Panel panel) { try{ Bitmap animatedGif = new Bitmap(path ); Grap ...

  7. The last packet successfully received from the server was 2,926,157 milliseconds ago. The last packet sent successfully to the server was 2,926,158 milliseconds ago. is longer than the server configured value of 'wait_timeout'. 解决办法

    Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully rec ...

  8. low-rank 的相关求解方法 (CODE) Low-Rank Matrix Recovery and Completion via Convex Optimization

    (CODE) Low-Rank Matrix Recovery and Completion via Convex Optimization 这个是来自http://blog.sina.com.cn/ ...

  9. mysql5.7.10免安装版出现的问题及应对

    在对应目录下新建my.ini [mysqld] # 设置mysql的安装目录 basedir=D:\mysql-5.7.10 # 设置mysql数据库的数据的存放目录,必须是data datadir= ...

  10. HTML5资料

    1 Canvas教程 <canvas>是一个新的用于通过脚本(通常是JavaScript)绘图的HTML元素.例如,他可以用于绘图.制作图片的组合或者简单的动画(当然并不那么简单).It ...