Maven Tomcat7插件“在类路径上检测到jcl-over-slf4j.jar和slf4j-jcl.jar”

时间:2017-02-17 22:43:19

标签: java maven slf4j

我正在尝试将旧的maven / eclipse项目转换为pur maven项目,但更难的部分是转换此项目的tomcat启动配置。

为此,我使用tomcat7-maven-plugin:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <!-- On prend la version 2.1 pour avoir la dépendance Tomcat en version 7.0.37 -->
    <version>2.1</version>
    <!-- Test d&#795;’exclusion -->
    <!--<dependencies>-->
    <!--<dependency>-->
        <!--<groupId>org.apache.tomcat.maven</groupId>-->
        <!--<artifactId>tomcat7-maven-plugin</artifactId>-->
        <!--<version>2.1</version>-->
        <!--<exclusions>-->
        <!--<exclusion>-->
            <!--<groupId>org.slf4j</groupId>-->
            <!--<artifactId>jcl-over-slf4j</artifactId>-->
        <!--</exclusion>-->
        <!--</exclusions>-->
    <!--</dependency>-->
    <!--</dependencies>-->

    <configuration>
    <additionalConfigFilesDir>tools/tomcat</additionalConfigFilesDir> <<<--- Pour essayer de faire prendre en compte le catalina.properties, mais je n’ai pas pu m’en assurer pour l’instant
    <contextFile>tools/tomcat/context.xml</contextFile>
    <serverXml>tools/tomcat/server.xml</serverXml>
    <tomcatUsers>tools/tomcat/tomcat-users.xml</tomcatUsers>
    <tomcatWebXml>tools/tomcat/web.xml</tomcatWebXml>
    <mode>context</mode>         <<<--- Je n’arrive pas à savoir que fait cette ligne
    <charset>ISO-8859-15</charset>
    <systemProperties>
        <CATALINA_HOME>C:\[…]\Tomcat</CATALINA_HOME>
        <CATALINA_BASE>C:\[…]\Tomcat</CATALINA_BASE>
        <!-- Report de "VM arguments" du lauch config d’eclipse -->
        <JAVA_OPTS>
        […]
        -XX:PermSize=96m
        -XX:MaxPermSize=256m
        -Dcom.sun.management.jmxremote
        -Dcatalina.base="C:\[…]\workspaces\[…]\.metadata\.plugins\org.eclipse.wst.server.core\tmp0"
        -Dcatalina.home="C:\[…]\Tomcat"
        <!--  -Dwtp.deploy="C:\[…]\workspaces\[…]\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps" -->
        -Djava.endorsed.dirs="C:\[…]\Tomcat\endorsed"
        -Dcatalina.properties="C:\[…]\workspaces\[…]\tools\tomcat\catalina.properties"
        </JAVA_OPTS>
        <!-- Report de "Environment" du lauch config d’eclipse -->
        […]
        <CLASSPATH>[…]</CLASSPATH>
        […]
        <NLS_DATE_FORMAT>YYYY-MM-DD HH24:MI:SS</NLS_DATE_FORMAT>
        <NLS_LANG>FRENCH_FRANCE</NLS_LANG>
        <ORACLE_HOME>[…]</ORACLE_HOME>
        […]
    </systemProperties>
    </configuration>
</plugin>

<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <!-- On prend la version 2.1 pour avoir la dépendance Tomcat en version 7.0.37 --> <version>2.1</version> <!-- Test d&#795;’exclusion --> <!--<dependencies>--> <!--<dependency>--> <!--<groupId>org.apache.tomcat.maven</groupId>--> <!--<artifactId>tomcat7-maven-plugin</artifactId>--> <!--<version>2.1</version>--> <!--<exclusions>--> <!--<exclusion>--> <!--<groupId>org.slf4j</groupId>--> <!--<artifactId>jcl-over-slf4j</artifactId>--> <!--</exclusion>--> <!--</exclusions>--> <!--</dependency>--> <!--</dependencies>--> <configuration> <additionalConfigFilesDir>tools/tomcat</additionalConfigFilesDir> <<<--- Pour essayer de faire prendre en compte le catalina.properties, mais je n’ai pas pu m’en assurer pour l’instant <contextFile>tools/tomcat/context.xml</contextFile> <serverXml>tools/tomcat/server.xml</serverXml> <tomcatUsers>tools/tomcat/tomcat-users.xml</tomcatUsers> <tomcatWebXml>tools/tomcat/web.xml</tomcatWebXml> <mode>context</mode> <<<--- Je n’arrive pas à savoir que fait cette ligne <charset>ISO-8859-15</charset> <systemProperties> <CATALINA_HOME>C:\[…]\Tomcat</CATALINA_HOME> <CATALINA_BASE>C:\[…]\Tomcat</CATALINA_BASE> <!-- Report de "VM arguments" du lauch config d’eclipse --> <JAVA_OPTS> […] -XX:PermSize=96m -XX:MaxPermSize=256m -Dcom.sun.management.jmxremote -Dcatalina.base="C:\[…]\workspaces\[…]\.metadata\.plugins\org.eclipse.wst.server.core\tmp0" -Dcatalina.home="C:\[…]\Tomcat" <!-- -Dwtp.deploy="C:\[…]\workspaces\[…]\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps" --> -Djava.endorsed.dirs="C:\[…]\Tomcat\endorsed" -Dcatalina.properties="C:\[…]\workspaces\[…]\tools\tomcat\catalina.properties" </JAVA_OPTS> <!-- Report de "Environment" du lauch config d’eclipse --> […] <CLASSPATH>[…]</CLASSPATH> […] <NLS_DATE_FORMAT>YYYY-MM-DD HH24:MI:SS</NLS_DATE_FORMAT> <NLS_LANG>FRENCH_FRANCE</NLS_LANG> <ORACLE_HOME>[…]</ORACLE_HOME> […] </systemProperties> </configuration> </plugin>

当我执行命令行«mvn tomcat7:run»时出现此错误


    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/C:/[…]/target/mdg-web/WEB-INF/lib/slf4j-jcl-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/C:/[…]/WEB-INF/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Detected both jcl-over-slf4j.jar AND slf4j-jcl.jar on the class path, preempting StackOverflowError. 
    SLF4J: See also http://www.slf4j.org/codes.html#jclDelegationLoop for more details.
    [ERROR] ContextLoader - Context initialization failed java.lang.IllegalStateException: Cannot load configuration class: com.[…].SocleCacheConfiguration
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:368)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:244)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:633)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
        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:745)
    Caused by: java.lang.ExceptionInInitializerError
        at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:73)
        at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:42)
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
        at com.[…].SocleCacheConfiguration.(SocleCacheConfiguration.java:25)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:274)
        at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:386)
        at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
        at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
        at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
        at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:118)
        at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:92)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:358)
        ... 16 more
    Caused by: java.lang.IllegalStateException: Detected both jcl-over-slf4j.jar AND slf4j-jcl.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#jclDelegationLoop for more details.
        at org.slf4j.impl.JCLLoggerFactory.(JCLLoggerFactory.java:57)
        ... 33 more

我理解错误,2 lib互相打电话。 所以我试图从WEB / lib中删除«slf4j-jcl.jar»并且没有出现错误。但是这种手动解决方法是不可接受的。 使用«-e -X»选项我从maven插件中看到了«jcl-over-slf4j.jar»。

我的目标是从tomcat启动中排除这个«jcl-over-slf4j.jar»,但我不知道如何。 帮助欢迎...或任何解决此问题的想法。

0 个答案:

没有答案