jcasbin / redis-watcher

Redis watcher for jCasbin
https://github.com/casbin/jcasbin
Apache License 2.0
4 stars 11 forks source link

slf4j multiple binding issue #24

Closed JCereal closed 2 years ago

JCereal commented 2 years ago

After adding redis-watcher as a gradle dependency, I encountered multiple SLF4J bindings issue:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/*******/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.33/463d6549ba948665ca0f874a0c520822afdf6ca2/slf4j-simple-1.7.33.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/*******/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.10/f69d97ef3335c6ab82fc21dfb77ac613f90c1221/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.SimpleLoggerFactory loaded from file:/Users/*******/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.33/463d6549ba948665ca0f874a0c520822afdf6ca2/slf4j-simple-1.7.33.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.SimpleLoggerFactory
    at org.springframework.util.Assert.instanceCheckFailed(Assert.java:702)
    at org.springframework.util.Assert.isInstanceOf(Assert.java:621)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:294)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:118)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:232)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:213)

I found this might be caused by the watcher's dependency on slf4j-simple: https://github.com/jcasbin/redis-watcher/blob/master/pom.xml#L63-L67. As a library, might it be a good idea to only depend on the slf4j-api?

Also, I didn't see any code using slf4j, so maybe we can remove this dependency? I am not 100% sure. Please kindly help with this issue, thanks.

casbin-bot commented 2 years ago

@tangyang9464 @seriouszyx @elfisworking @fangzhengjin

JCereal commented 2 years ago

Excluding slf4j-simple in gradle is a work-around, but better to solve this from the root cause.

Add this to build script:

configurations.all {
    exclude module: 'slf4j-simple'
}
hsluoyz commented 2 years ago

@seriouszyx

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 1.3.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: