简体   繁体   English

春季项目部署向org.apache.commons.logging.Log抛出ClassNotFoundException

[英]Spring project deployment throws ClassNotFoundException for org.apache.commons.logging.Log

I have Spring Web app built with maven. 我有使用Maven构建的Spring Web应用程序。 I excluded commons-logging from spring to use SLF4J and Logback. 我从spring排除了commons-logging,以使用SLF4J和Logback。 But for some reason, the deployment fails with the following error 但是由于某种原因,部署失败并显示以下错误

Caused by: java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/Log;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2436)
    at java.lang.Class.getDeclaredFields(Class.java:1806)
    at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
    at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:256)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:132)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:334)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5095)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 40 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1295)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1147)
    ... 54 more

I'm not sure what is triggering the Apps server to look for commons logging and then complain that it can't find it. 我不确定是什么触发了Apps服务器来查找公用日志,然后抱怨找不到它。 I'm trying to find out the misconfiguration in my app that could be causing this (maven's dependency tree did not show commons logging at all). 我试图找出可能导致此问题的应用程序配置错误(Maven的依赖树根本没有显示公共日志)。 Here's my Maven configuration 这是我的Maven配置

<!-- Spring MVC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring-framework.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-oracle</artifactId>
        <version>1.1.0.RELEASE</version>
    </dependency>

        <!-- Jackson -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.databind-version}</version>
        </dependency>
        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>
        <!-- Other Web dependencies -->
<!--        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp.version}</version>
            <scope>provided</scope>
        </dependency>
 -->
        <!-- Spring and Transactions -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <!-- Logging with SLF4J & LogBack -->

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback.version}</version>
        </dependency>

        <!-- Test Artifacts -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring-framework.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

Dependency Tree: 依赖树:

依赖树

I also checked for any hidden references to apache commons. 我还检查了对Apache Commons的任何隐藏引用。 But I couldn't find any. 但是我找不到任何东西。 Not sure what's causing the error. 不知道是什么原因引起的错误。 I need to remove apache commons and make Spring use SLF4J and logback. 我需要删除apache commons,并使Spring使用SLF4J和logback。 Any insights are appreciated. 任何见解都表示赞赏。

You can try to add jcl-over-slf4j dependency, this is needed according to this documentation . 您可以尝试添加jcl-over-slf4j依赖项,根据此文档 ,这是必需的。

<dependency>                                    
    <groupId>org.slf4j</groupId>                
    <artifactId>jcl-over-slf4j</artifactId>    
    <version>${jcloverslf4j.version}</version>  
</dependency>

I hope it helps. 希望对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.apache.commons.logging.Log 无法解析 - org.apache.commons.logging.Log cannot be resolved 使用commons-beanutils在org.apache.commons.logging.LogFactory上引发ClassNotFoundException - Using commons-beanutils throws ClassNotFoundException on org.apache.commons.logging.LogFactory java.lang.ClassNotFoundException:org.apache.commons.logging.LogFactory - java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory 如何修复ClassNotFoundException:org.apache.commons.logging.LogFactory? - How to fix ClassNotFoundException: org.apache.commons.logging.LogFactory? 在 Spring 项目中禁用 Apache Commons 日志记录 - Disable Apache Commons Logging in Spring project 使用org.apache.commons.logging写日志文件 - Write log file using org.apache.commons.logging 如何使用org.apache.commons.logging登录到文件? - How to log to a file with org.apache.commons.logging? java.lang.ClassNotFoundException:org.apache.commons.logging.impl.LogFactoryImpl - java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl Quarkus rest 客户端 ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl 在本机模式 - Quarkus rest client ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl in native mode 使用部署程序集在eclipse中java.lang.ClassNotFoundException:org.apache.commons.dbcp2.BasicDataSource - java.lang.ClassNotFoundException: org.apache.commons.dbcp2.BasicDataSource in eclipse using deployment assembly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM