sunmingtao / sample-code

3 stars 4 forks source link

Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path #360

Closed sunmingtao closed 5 days ago

sunmingtao commented 5 days ago

la-ris-scheduler failed to start using the latest RDC library (build off master branch)

16:15:45.462 java[24023]: Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
16:15:45.462 java[24023]:    at org.slf4j.reload4j.Reload4jLoggerFactory.<clinit>(Reload4jLoggerFactory.java:54)
16:15:45.462 java[24023]:    ... 10 more
16:15:45.981 java[24041]: SLF4J: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. 
16:15:45.981 java[24041]: SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
sunmingtao commented 5 days ago

According to https://www.slf4j.org/codes.html#log4jDelegationLoop

Note that since reload4j provides the log4j 1.x API, reload4j.jar and log4j-over-slf4j.jar cannot be present simultaneously on your classpath.

So the fix is excluding slf4j-reload4j .

<dependency>
    <groupId>au.gov.nla</groupId>
    <artifactId>rdcevent</artifactId>
    <version>2.2.0-SNAPSHOT</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-reload4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>