How to resolve the error Class path contains multiple SLF4J bindings while using selenium-server-4.0.0-alpha-5.jar
and gerrit-acceptance-framework-3.1.4.jar
Error stack trace:
[RemoteTestNG] detected TestNG version 7.2.0
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/DELL/Desktop/selenium/selenium-server-4.0.0-alpha-5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/DELL/.m2/repository/com/google/gerrit/gerrit-acceptance-framework/3.1.4/gerrit-acceptance-framework-3.1.4.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.JDK14LoggerFactory]
Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882}) on port 24218
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882}) on port 48737
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882}) on port 5045
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
===============================================
Suite
Total tests run: 3, Passes: 0, Failures: 3, Skips: 0
===============================================
This error message...
...implies that there are more than one SLF4J bindings present on the class path.
Multiple bindings were found on the class path
As per the documentation:
From the error stacktrace it is pretty evident that
StaticLoggerBinder.class
seems to be available in both the following class paths:C:/Users/DELL/Desktop/selenium/selenium-server-4.0.0-alpha-5.jar!/org/slf4j/impl
C:/Users/DELL/.m2/repository/com/google/gerrit/gerrit-acceptance-framework/3.1.4/gerrit-acceptance-framework-3.1.4.jar!/org/slf4j/impl
Solution
When multiple bindings are available on the class path, select one and only one binding you wish to use, and remove the other bindings. The list of locations that SLF4J provides in this warning usually provides sufficient information to identify the dependency transitively pulling in an unwanted SLF4J binding into your project. So in your project's
pom.xml
file you have to exclude one of the SLF4J binding when declaring the unscrupulous dependency. As an example, to excludeStaticLoggerBinder.class
fromselenium-server-4.0.0-alpha-5.jar
:As an alternative you can also exclude the
StaticLoggerBinder.class
fromgerrit-acceptance-framework-3.1.4.jar