Bug 520754 - Multiple bindings messing up SLF4J and muting console
Summary: Multiple bindings messing up SLF4J and muting console
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 514326
Blocks:
  Show dependency tree
 
Reported: 2017-08-09 09:29 EDT by Alex CLA
Modified: 2021-04-19 13:23 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex CLA 2017-08-09 09:29:21 EDT
Hello,

I recently started using a fresh copy of Neon and I cannot get Maven output to be redirected to the console. Looking into it, I think m2e is being confused by some other plugin:

org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized.  Will retry after the state location is initialized.
org.eclipse.m2e.logback.configuration: Logback config file: C:\dev\branch\ws\relbranch-01\.metadata\.plugins\org.eclipse.m2e.logback.configuration\logback.1.7.0.20160603-1933.xml
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://292.fwk1632789609:1/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://292.fwk1632789609:2/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.Log4jLoggerFactory]
org.eclipse.m2e.logback.configuration: SLF4J logger factory is not an instance of LoggerContext: org.slf4j.impl.Log4jLoggerFactory
log4j:WARN No appenders could be found for logger (com.gradleware.tooling.toolingutils.distribution.PublishedGradleVersions).
log4j:WARN Please initialize the log4j system properly.

It appears to me that there are 2 sources providing bindings for slf4j? 

Should m2e not instantiate a private slf4j instance (separate class loader) and specifically target that one? I mean, this could happen with any plugin that happens to pull in some slf4j binding.

It is not even clear to me whether the source of these bindings is the same bundle or not (i am not familiar with the bundleresource syntax). Is there some way for me to tell which plugins 292.fwk1632789609:1 and 292.fwk1632789609:2 are?
Comment 1 Alex CLA 2017-08-09 09:42:01 EDT
Just looking at the list of plugins, I *think* the culprits are:

org.slf4j.impl.log4j12,1.7.2.v20131105-2200

org.eclipse.m2e.maven.runtime.slf4j.simple,1.7.0.20160603-1931

Not sure where the first one is coming from...
Comment 2 Alex CLA 2017-08-09 09:47:39 EDT
Ok I removed this from bundles.info:

org.slf4j.impl.log4j12,1.7.2.v20131105-2200

... and now my m2eclipse console works.

I'll look to see if I can find out which feature pulls this in, because my eclipse is mostly core features. I install it with p2 provisioning but it's mostly JDT, EGit, M2Eclipse to which I add in a second provisioning operation some extras (findbugs, jacoco).

I think it's very likely some core eclipse feature is creating the conflict.
Comment 3 Matthew Piggott CLA 2018-01-11 12:44:05 EST
In my install org.slf4j.impl.log4j12 is brought in by jgit.
Comment 4 Brian de Alwis CLA 2018-01-11 14:02:37 EST
org.eclipse.m2e.maven.runtime.slf4j.simple's MANIFEST.MF includes a note:

Bundle-Description: This bundle provides SLF4j implementation and
    configuration required to run m2e embedded Maven runtime in
    external JVM. This bundle is NOT a general purpose slf4j-simple
    OSGi bundle, it does NOT export  any packages and it CANNOT be
    used as an OSGI SLF4J implementation.  This is suboptimal and
    a better solution would be to ither include slf4j-simple as a
    resource in org.eclipse.m2e.maven.runtime or use SLF4J
    implementation of the running m2e instance. I could not find
    an easy way to implement either of the better solutions, so
    this one will have to do for now.   This bundle is referenced
    as Require-Bundle by org.eclipse.m2e.maven.runtime to force
    installation of this bundle whenever m2e embedded maven runtime
    is installed. Because no packages are exported, this does not
    pollute OSGi classpath.  Provide-Capability/Require-Capability
    would be cleaner, but I don't know if these are supported bu P2.
Comment 5 Alex CLA 2018-03-24 12:33:41 EDT
I should mention that things seem to work fine for me now on Oxygen.

Since it is fixed in the newest versions there is little value in patching older ones: people will move on and there will be no point.

I am closing this as resovled...
Comment 6 Denis Roy CLA 2021-04-19 13:23:09 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/