Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Trouble when trying to use log4j(Error "SLF4J: Class path contains multiple SLF4J bindings")
Trouble when trying to use log4j [message #1436194] Thu, 02 October 2014 14:38 Go to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Hello,

I tried the recipe http://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Logging to inject an instance of the default java.util.Logger. This worked fine.

However, when adding the plugin org.eclipse.fx.core.log4j in order to use the log4j implementation, I get the following error when the logger.info(...) is called :

Quote:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://176.fwk1616974404:1/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://176.fwk1616974404: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]
Exception in thread "JavaFX Application Thread" java.lang.StackOverflowError
at java.util.Hashtable.containsKey(Unknown Source)
at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:57)
at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
at org.apache.log4j.Category.<init>(Category.java:56)
at org.apache.log4j.Logger.<init>(Logger.java:36)


I've found only few references of this error on the net (e.g. http://www.slf4j.org/codes.html#multiple_bindings, http://stackoverflow.com/questions/14024756/slf4j-class-path-contains-multiple-slf4j-bindings and http://stackoverflow.com/questions/18721142/multiple-slf4j-bindings-in-eclipse-rcp-plugin, but none of the proposed solutions seem applicable : there's no dependency defined in the POM, there is no conflict on the classpath (as the bindings stem apparently twice from the same plugin) .

Any idea of how to solve this ... ? Perhaps it's more of a question regarding log4j ... ?

Thomas
Re: Trouble when trying to use log4j [message #1436252 is a reply to message #1436194] Thu, 02 October 2014 16:18 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I think slf4j is causing this troubles - I've seen this problem myself
just yesterday myself when I dropped slf4j into my runtime config. So
there's something heavily crazy going on with slf4j. Need to debug
please file a bug report!

Tom

On 02.10.14 07:38, Thomas Elskens wrote:
> Hello,
>
> I tried the recipe
> http://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Logging to inject an
> instance of the default java.util.Logger. This worked fine.
> However, when adding the plugin org.eclipse.fx.core.log4j in order to
> use the log4j implementation, I get the following error when the
> logger.info(...) is called :
> Quote:
>> SLF4J: Class path contains multiple SLF4J bindings.
>> SLF4J: Found binding in
>> [bundleresource://176.fwk1616974404:1/org/slf4j/impl/StaticLoggerBinder.class]
>>
>> SLF4J: Found binding in
>> [bundleresource://176.fwk1616974404: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]
>> Exception in thread "JavaFX Application Thread"
>> java.lang.StackOverflowError
>> at java.util.Hashtable.containsKey(Unknown Source)
>> at
>> org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:57)
>> at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
>> at
>> org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
>> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>> at org.apache.log4j.Category.<init>(Category.java:56)
>> at org.apache.log4j.Logger.<init>(Logger.java:36)
>
>
> I've found only few references of this error on the net (e.g.
> http://www.slf4j.org/codes.html#multiple_bindings,
> http://stackoverflow.com/questions/14024756/slf4j-class-path-contains-multiple-slf4j-bindings
> and
> http://stackoverflow.com/questions/18721142/multiple-slf4j-bindings-in-eclipse-rcp-plugin,
> but none of the proposed solutions seem applicable : there's no
> dependency defined in the POM, there is no conflict on the classpath (as
> the bindings stem apparently twice from the same plugin) .
> Any idea of how to solve this ... ? Perhaps it's more of a question
> regarding log4j ... ?
>
> Thomas
>
Re: Trouble when trying to use log4j [message #1436870 is a reply to message #1436252] Fri, 03 October 2014 14:30 Go to previous messageGo to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Issue reported as https://bugs.eclipse.org/bugs/show_bug.cgi?id=445885

Please note that while retesting today, I only get the warning, and no more the StackOverflowError.
Re: Trouble when trying to use log4j [message #1439534 is a reply to message #1436870] Tue, 07 October 2014 08:50 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
SLF4j throws this error if more than one implemenation of its API is found on the classpath. But anyway ... if I understand you correctly, you want to use LOG4j (and not SLF4J). Is that correct? If so, there should not be any SLF4J error.

I tried to reproduce the issue, but failed. I did this:

- Create a new e4-fx application with the wizard
- add org.eclipse.fx.core.log4j to the feature.xml
- add plugin publishing log4j packages to feature.xml
- add fragment with log4j configuration to feature.xml

I then injected the Logger into a lifecycle handler
public class LifeCycleManager {
	@PostContextCreate
	Boolean postContextCreate(@Log Logger logger) {
		logger.debug("DEBUG");
		logger.info("DEBUG");
		logger.warning("DEBUG");
		logger.error("ERROR", new Exception("Just a exception"));
		return false;
	}
}

The loggging works for me. I also started the application using the osgi console (-console) and verified with ss -> there is no slf4j bundle beeing started.

[Updated on: Tue, 07 October 2014 08:59]

Report message to a moderator

Re: Trouble when trying to use log4j [message #1439539 is a reply to message #1436252] Tue, 07 October 2014 08:58 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi Tom,

if you look at the included bundles with ss, do you see more than one implementation of the slf4j API on the list? Maybe two of logback, slf4j.log4j, slf4j.simple, slf4j.nop, etc ...

I have seen this issue before, when I used "Add required bundles". Because slf4j.log4j is a fragment it gets added as soon as slf4j.api is around.

Greetings
Christoph

Thomas Schindl wrote on Thu, 02 October 2014 18:18
I think slf4j is causing this troubles - I've seen this problem myself
just yesterday myself when I dropped slf4j into my runtime config. So
there's something heavily crazy going on with slf4j. Need to debug
please file a bug report!

Tom

On 02.10.14 07:38, Thomas Elskens wrote:
> Hello,
>
> I tried the recipe
> http://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Logging to inject an
> instance of the default java.util.Logger. This worked fine.
> However, when adding the plugin org.eclipse.fx.core.log4j in order to
> use the log4j implementation, I get the following error when the
> logger.info(...) is called :
> Quote:
>> SLF4J: Class path contains multiple SLF4J bindings.
>> SLF4J: Found binding in
>> [bundleresource://176.fwk1616974404:1/org/slf4j/impl/StaticLoggerBinder.class]
>>
>> SLF4J: Found binding in
>> [bundleresource://176.fwk1616974404: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]
>> Exception in thread "JavaFX Application Thread"
>> java.lang.StackOverflowError
>> at java.util.Hashtable.containsKey(Unknown Source)
>> at
>> org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:57)
>> at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
>> at
>> org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
>> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>> at org.apache.log4j.Category.<init>(Category.java:56)
>> at org.apache.log4j.Logger.<init>(Logger.java:36)
>
>
> I've found only few references of this error on the net (e.g.
> http://www.slf4j.org/codes.html#multiple_bindings,
> http://stackoverflow.com/questions/14024756/slf4j-class-path-contains-multiple-slf4j-bindings
> and
> http://stackoverflow.com/questions/18721142/multiple-slf4j-bindings-in-eclipse-rcp-plugin,
> but none of the proposed solutions seem applicable : there's no
> dependency defined in the POM, there is no conflict on the classpath (as
> the bindings stem apparently twice from the same plugin) .
> Any idea of how to solve this ... ? Perhaps it's more of a question
> regarding log4j ... ?
>
> Thomas
>

Re: Trouble when trying to use log4j [message #1439557 is a reply to message #1439539] Tue, 07 October 2014 09:25 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I did something nasty because I copied stuff (jars, ...) together to
assemble a bundle with its prereqs so the error is most likely really bogus.

Tom

On 07.10.14 10:58, Christoph Keimel wrote:
> Hi Tom,
>
> if you look at the included bundles with ss, do you see more than one
> implementation of the slf4j API on the list? Maybe two of logback,
> slf4j.log4j, slf4j.simple, slf4j.nop, etc ...
>
> I have seen this issue before, when I used "Add required bundles".
> Because slf4j.log4j is a fragment it gets added as soon as slf4j.api is
> around.
>
> Greetings
> Christoph
>
> Thomas Schindl wrote on Thu, 02 October 2014 18:18
>> I think slf4j is causing this troubles - I've seen this problem myself
>> just yesterday myself when I dropped slf4j into my runtime config. So
>> there's something heavily crazy going on with slf4j. Need to debug
>> please file a bug report!
>>
>> Tom
>>
>> On 02.10.14 07:38, Thomas Elskens wrote:
>> > Hello,
>> > > I tried the recipe
>> > http://wiki.eclipse.org/Efxclipse/Runtime/Recipes#Logging to inject an
>> > instance of the default java.util.Logger. This worked fine.
>> > However, when adding the plugin org.eclipse.fx.core.log4j in order to
>> > use the log4j implementation, I get the following error when the
>> > logger.info(...) is called :
>> > Quote:
>> >> SLF4J: Class path contains multiple SLF4J bindings.
>> >> SLF4J: Found binding in
>> >>
>> [bundleresource://176.fwk1616974404:1/org/slf4j/impl/StaticLoggerBinder.class]
>>
>> >>
>> >> SLF4J: Found binding in
>> >>
>> [bundleresource://176.fwk1616974404: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]
>> >> Exception in thread "JavaFX Application Thread"
>> >> java.lang.StackOverflowError
>> >> at java.util.Hashtable.containsKey(Unknown Source)
>> >> at
>> >>
>> org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:57)
>> >> at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
>> >> at
>> >>
>> org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
>> >> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>> >> at org.apache.log4j.Category.<init>(Category.java:56)
>> >> at org.apache.log4j.Logger.<init>(Logger.java:36)
>> > > > I've found only few references of this error on the net (e.g.
>> > http://www.slf4j.org/codes.html#multiple_bindings,
>> >
>> http://stackoverflow.com/questions/14024756/slf4j-class-path-contains-multiple-slf4j-bindings
>>
>> > and
>> >
>> http://stackoverflow.com/questions/18721142/multiple-slf4j-bindings-in-eclipse-rcp-plugin,
>>
>> > but none of the proposed solutions seem applicable : there's no
>> > dependency defined in the POM, there is no conflict on the classpath
>> (as
>> > the bindings stem apparently twice from the same plugin) .
>> > Any idea of how to solve this ... ? Perhaps it's more of a question
>> > regarding log4j ... ?
>> > > Thomas
>> >
>
>
Re: Trouble when trying to use log4j [message #1439561 is a reply to message #1439539] Tue, 07 October 2014 09:26 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
I have tested a little further:
- Use "http://download.eclipse.org/efxclipse/runtime-nightly/site/" as an target platfrom
- add org.slf4j as a dependency
- "Add required plug-ins" will add the ch.qos.logback stuff as well as org.slf4j.impl.log4j

You only need one of the two, depending on which implementation you would like to use as a backend for slf4j: logback or log4j
=> For example: removing all the ch.qos.logback.* plugins will get rid of the warning.
Re: Trouble when trying to use log4j [message #1439575 is a reply to message #1439539] Tue, 07 October 2014 09:45 Go to previous messageGo to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Christophe,

Problem solved ! To be complete, I removed the following bundles of the target definition file : org.slf4j.ext, org.slf4j.impl.log4j12, org.slf4j.jcl, org.slf4j.jul.
Remainder : org.slf4j.api and org.slf4j.log4j.

I cannot remove slf4j.log4j too, because in that case Eclipse complains about a missing appender :
Quote:

log4j:WARN No appenders could be found for logger(parts.EmployerListViewPart).
log4j:WARN Please initialize the log4j system properly

I'll put a copy of this message in bugzilla, too.

Thomas
Re: Trouble when trying to use log4j [message #1439595 is a reply to message #1439575] Tue, 07 October 2014 10:06 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi Thomas

If you do not want to use slf4j you can remove
- org.slf4j.api
- org.slf4j.log4j
- org.eclipse.fx.core.slf4j

Greetings
Christoph
Re: Trouble when trying to use log4j [message #1439596 is a reply to message #1439575] Tue, 07 October 2014 10:07 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi Thomas

Do you want to use SLF4J or not?
If you do not want to use slf4j you can safely remove
- org.slf4j.api
- org.slf4j.log4j
- org.eclipse.fx.core.slf4j

Greetings
Christoph
Re: Trouble when trying to use log4j [message #1439600 is a reply to message #1439596] Tue, 07 October 2014 10:10 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Sorry for the double post ... I didn't realy want to send that yet. What I wanted to add:

The warning "log4j:WARN No appenders could be found" is a message from LOG4J and means, that you have not configured log4j, for example with a log4.xml configuration file.
Re: Trouble when trying to use log4j [message #1439659 is a reply to message #1439600] Tue, 07 October 2014 11:26 Go to previous messageGo to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Christophe,

Indeed I don't need slf4j, only log4j - so I removed the three dependencies and provided some basic configuration by means of a log4j.properties file.
I guess I misinterpreted the efxclipse wiki by supposing configuration of log4j was already done (which now I think of it, would not be very meaningful).
Perhaps interesting for others, too : http://stackoverflow.com/questions/5150415/log4j-under-osgi-eclipse-rcp.

Everything seems to work very well now.

Thanks a lot !

Thomas
Re: Trouble when trying to use log4j [message #1439673 is a reply to message #1439659] Tue, 07 October 2014 11:41 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
.... on my never ending list of ideas ;-) there's a feature which
integrates our logger stuff into the world of ConfigAdmin.

Tom

On 07.10.14 13:26, Thomas Elskens wrote:
> Christophe,
>
> Indeed I don't need slf4j, only log4j - so I removed the three
> dependencies and provided some basic configuration by means of a
> log4j.properties file. I guess I misinterpreted the efxclipse wiki by
> supposing configuration of log4j was already done (which now I think of
> it, would not be very meaningful).
> Perhaps interesting for others, too :
> http://stackoverflow.com/questions/5150415/log4j-under-osgi-eclipse-rcp.
> Everything seems to work very well now.
> Thanks a lot !
>
> Thomas
>
Previous Topic:Demo Sources from JavaOne Presentations
Next Topic:Update site Jemmy not found
Goto Forum:
  


Current Time: Tue Jan 14 12:29:32 GMT 2025

Powered by FUDForum. Page generated in 0.03503 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top