ClassCastException - org.slf4j.impl.JDK14LoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext

邮差的信 提交于 2019-12-24 19:19:35

问题


Getting the above exception when I try this :

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;

private static final Logger LOGGER = LoggerFactory.getLogger( ABC.class.getName() );
public String greet() {
    LOGGER.info("START1:: [ {} ] , [ {} ] , {}", ABC.class.getName(),"greet",123);
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

Have checked my maven dependencies - this is what I have :

<dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.3</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.2.3</version>
        <scope>compile</scope>
    </dependency>

Not sure what I am doing wrong. Environment is a war file deployed in weblogic 10.2.3 and jre 1.7

EDIT: When I search for JDK14LoggerFactory cannot find this class in any of the JARs on classpath ( within web application )

UPDATE1: Looking into which jar contains the file - JDK14LoggerFactory : found following in weblogic:

\Oracle_Home\wlserver\modules\features\weblogic.server.merged.jar \Oracle_Home\wlserver\modules\org.slf4j.jdk14_1.0.0.0_1-6-1.jar

UPDATE2: Looking into which jar contains the file - LoggerFactory : found following in weblogic:

\Oracle_Home\oracle_common\modules\oracle.dms_12.1.3\dms.jar
\Oracle_Home\oracle_common\modules\oracle.dms_12.1.3\dms.jar
\Oracle_Home\oracle_common\modules\oracle.odl_12.1.3\ojdl2.jar
\Oracle_Home\oracle_common\modules\oracle.odl_12.1.3\ojdl2.jar
\Oracle_Home\wlserver\modules\clients\com.oracle.webservices.wls.jaxws- 
 wlswss-client.jar
 \Oracle_Home\wlserver\modules\com.bea.core.apache.log4j_1.3.0.0_1-2-15.jar
 \Oracle_Home\wlserver\modules\features\weblogic.server.merged.jar
 \Oracle_Home\wlserver\modules\features\weblogic.server.merged.jar
 \Oracle_Home\wlserver\modules\hibernate.validator_1.0.0.0_4-1-0.jar
 \Oracle_Home\wlserver\modules\org.jboss.weld.core_2.0.0.0_1-1-18.Final.jar
 \Oracle_Home\wlserver\modules\org.slf4j.api_1.0.0.0_1-6-1.jar
 \Oracle_Home\wlserver\server\lib\consoleapp\APP-INF\lib\log4j-1.2.8.jar

So looks like this is the issue - now I need to suppress class loading from the above locations and FORCE it to load from WEB-INF\lib folder. Will post this as a separate question

来源:https://stackoverflow.com/questions/55886819/classcastexception-org-slf4j-impl-jdk14loggerfactory-cannot-be-cast-to-ch-qos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!