Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple SLF4J bindings #354

Closed
kwin opened this issue Oct 7, 2021 · 4 comments · Fixed by #369
Closed

Multiple SLF4J bindings #354

kwin opened this issue Oct 7, 2021 · 4 comments · Fixed by #369
Labels
bug Something isn't working
Milestone

Comments

@kwin
Copy link
Member

kwin commented Oct 7, 2021

Eclipse comes with a default binding in Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/8/0/.cp/org/slf4j/impl/StaticLoggerBinder.class and m2e contains one in https://github.com/eclipse-m2e/m2e-core/blob/master/m2e-maven-runtime/org.eclipse.m2e.maven.runtime.slf4j.simple/pom.xml as well. So whenever you install "M2E - SLF4J over Logback Logging" you get this warning in the Maven Console.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:...plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.18.1.20211004-1243/jars/slf4j-simple-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/.../Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/8/0/.cp/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]

That issue was already reported in https://bugs.eclipse.org/bugs/show_bug.cgi?id=506676.

@kwin
Copy link
Member Author

kwin commented Oct 8, 2021

This affects some standard distributions e.g. "Eclipse IDE for Enterprise Java and Web Developers (2021-09)" (https://git.eclipse.org/c/oomph/org.eclipse.oomph.git/tree/setups/org.eclipse.products.setup#n1986).

@HannesWell
Copy link
Contributor

HannesWell commented Oct 11, 2021

This is a long standing issue that was also reported in Bug 571577 and Bug 569662.

First of all this is just a warning that is not harmful. Nevertheless it is annoying and it confuses users.

The problem is that in MavenEmbeddedRuntime.addBundleClasspathEntries() fragments of dependencies of m2e.maven.runtime are also added to the classpath of a launched Maven-build JVM. Therefore for the required org.slf4j.api bundle, which is defined via the imported packages org.slf4j.*, also the bundle ch.qos.logback.slf4j is added to the classpath. ch.qos.logback.slf4j is a fragment of org.slf4j to 'connect' org.slf4j.api with the ch.qos.logback.classic bundle in the OSGi/Equinox runtime that Eclipse is.

The good thing is, that I think this problem can be solved if only fragments of m2e.maven.runtime itself are added to the classpath and not fragments of its direct dependencies. I think that was also the actual intention of Bug 536475 that introduced the add of fragments.
I can provide a PR as soon as PR #367 is submitted (that PR is not required but it has conflicting changes).

@mickaelistria mickaelistria added the bug Something isn't working label Oct 11, 2021
@mickaelistria
Copy link
Contributor

@HannesWell Is this something you want in 1.18.2 ? Should we wait for it?

@HannesWell
Copy link
Contributor

@HannesWell Is this something you want in 1.18.2 ? Should we wait for it?

That would be great, yes. I'm just preparing the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants