Eclipse running SpringBoot: SLF4J: Class path contains multiple SLF4J bindings - eclipse

Whenever I fire up a SpringBoot-based application (run as Maven build / goal spring-boot:run) I get the infamous SLF4J Warning:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/U:/eclipse/eclipse-jee/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/U:/eclipse/eclipse-jee/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 warning annoys me greatly because when demoing an application from Eclipse the first thing the potential customers or users are seeing is a big red superfluous warning. I HATE that! It looks so unprofessional!
Now - in principle the warning is clear: there are two SLF4J bindings and one should get rid of one of them. I found misc. descriptions of the same error some of which also explain how to locate the (usually transitive) dependency and then exclude one of them from the dependencies in the pom.
I tried that and non of these suggestions worked for me! Also the solution proposed in
Eclipse Maven: SLF4J: Class path contains multiple SLF4J bindings (namely to use an external Maven installation) did NOT work!
Looking closer at the paths listed in the warning I would claim, that there are already two bindings in eclipse itself (in the plugins org.eclipse.osgi... and in org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar) and that probably explains why my attempts were fruitless: mangling the application's pom doesn't change anything regarding these Eclipse-internal bindings. The mentioned append comes to the same conclusion: it's a bug inside eclipse.
But does anyone have an idea what it would need to get rid of that warning? I am open to all kind of "hacks"! Could one e.g. "massage" the ...m2e.maven.runtime.'s jar to no longer contain the org/slf4j/impl/StaticLoggerBinder.class (or probably rather its containing jar)? Or are there better/safer ways?
What would be needed to get rid of that warning in Eclipse?

for me Eclipse Maven: SLF4J: Class path contains multiple SLF4J bindings work. In Debian Linux I add /usr/share/maven to Window/Preferences/Maven/Installations and these warnings disappeared.

Related

issue SLF4J + OWL API Scala Eclipse

I have a problem with slf4j while programming in scala with Eclipse (Maven project):
I try to import an ontology with owl API.
Particularly, I try to use the command loadOntologyFromOntologyDocument to load an owl file and I get the following error:
SLF4J: Class path contains multiple SLF4J bindings.
I've already tried to delete useless dependencies and reload project. But it seems that dependencies are installed again everytime I run the code.
Does anyone has encountered this issue ?

NoClassDefFoundError (Could not initialize class org.apache.log4j.Log4jLoggerFactory)

I have a maven project under Eclipse Luna SR2 (4.4.2). This project uses slf4j through maven dependencies.
Infinitest is running continuous integration and it works in a lot of case, except for static slf4j declarations as
#Component
public class UnitProcessor implements Processor {
private static Logger logger = LoggerFactory.getLogger(UnitProcessor.class);
...
where I got this message
NoClassDefFoundError (Could not initialize class org.apache.log4j.Log4jLoggerFactory)
Of course, there's no exception nor problem in Eclipse itself when I run involved class. No problem in maven too.
Infinitest console wrote :
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/mde.DSI/.m2/repository/org/slf4j/slf4j-log4j12/1.5.10/slf4j-log4j12-1.5.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/mde.DSI/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.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.Log4jLoggerFactory]
SLF4J: The requested version 1.5.10 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
How to get out of this hell ?
Thanks

Unable to reset proxy in Eclipse MARS

I installed CDT on top of Eclipse MARS IDE for JAVA developers on Fedora 22. After a reboot, I am unable to reset proxy in Eclipse. When I click on Network Connections I get an error message The currently displayed page contains invalid values.
After the error message
The Active provider has to be set to 'Manual', but the drop down list is now missing.
Eclipse starts with the following messages:
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:
/root/workspace/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.6.2.20150902-0002.xml
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found
binding in
[bundleresource://472.fwk12572413:1/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[bundleresource://472.fwk12572413: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
[ch.qos.logback.classic.util.ContextSelectorStaticBinder]
org.eclipse.m2e.logback.configuration: Initializing logback
There are no messages even after the error is encountered. Which configuration file should I change to reset proxy?
Unfortunately this is known issue with the latest eclipse mars version.
Description could be found here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=479075
Workaround:
create file "org.eclipse.core.net.prefs" under ${eclipse.install.dir}/configuration/.settings with content:
nonProxiedHosts=localhost
Did you move your install directory ?
Because this exact same problem happend to me after I (brutally) moved the Eclipse install directories.
A re-install cleared the problem.

GWT compilation error, images and deferred binding

With three friends, I am developing an application with gwt (2.6). A few weeks ago, we started to use super dev mode. Everything works great, except that two of us cant use ImageBundles. It started when I wanted to include a SuggestBox, which apparently loads some images. GWT compile failed. I googled a lot, and I couldn't fix it, so I started to work on something else: Loading some images using an ImageResourceBundle. GWT compile failed. Same error. Workaround: loading images not using ImageResourceBundle. Whats really strange is: two of us are working with windows, one with ubuntu and I'm using a mac. The compile works fine with ubuntu and with one of the windows machines. On the other machines, the compilation error stays always the same no matter what we try:
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Computing all possible rebind results for 'com.google.gwt.user.client.ui.MenuBar.Resources'
Rebinding com.google.gwt.user.client.ui.MenuBar.Resources
Invoking generator com.google.gwt.resources.rebind.context.InlineClientBundleGenerator
[ERROR] No #com.google.gwt.resources.ext.ResourceGeneratorType was specifed for type com.google.gwt.resources.client.ImageResource or its supertypes
[ERROR] Errors in 'com/google/gwt/user/client/ui/MenuBar.java'
[ERROR] Line 212: Failed to resolve 'com.google.gwt.user.client.ui.MenuBar.Resources' via deferred binding
Computing all possible rebind results for 'com.google.gwt.user.client.ui.impl.ClippedImageImpl.Template'
Rebinding com.google.gwt.user.client.ui.impl.ClippedImageImpl.Template
Invoking generator com.google.gwt.safehtml.rebind.SafeHtmlTemplatesGenerator
Constructing interface com.google.gwt.user.client.ui.impl.ClippedImageImpl.Template
Generating method body for image()
[ERROR] Required annotation #Template not present on interface method public abstract com.google.gwt.safehtml.shared.SafeHtml image(com.google.gwt.safehtml.shared.SafeUri clearImage, com.google.gwt.safecss.shared.SafeStyles style)
[ERROR] Errors in 'com/google/gwt/user/client/ui/impl/ClippedImageImpl.java'
[ERROR] Line 104: Failed to resolve 'com.google.gwt.user.client.ui.impl.ClippedImageImpl.Template' via deferred binding
Computing all possible rebind results for 'com.google.gwt.user.client.ui.impl.ClippedImageImpl.DraggableTemplate'
Rebinding com.google.gwt.user.client.ui.impl.ClippedImageImpl.DraggableTemplate
Invoking generator com.google.gwt.safehtml.rebind.SafeHtmlTemplatesGenerator
Constructing interface com.google.gwt.user.client.ui.impl.ClippedImageImpl.DraggableTemplate
Generating method body for image()
[ERROR] Required annotation #Template not present on interface method public abstract com.google.gwt.safehtml.shared.SafeHtml image(com.google.gwt.safehtml.shared.SafeUri clearImage, com.google.gwt.safecss.shared.SafeStyles style)
[ERROR] Errors in 'com/google/gwt/user/client/ui/impl/ClippedImageImpl.java'
[ERROR] Line 96: Failed to resolve 'com.google.gwt.user.client.ui.impl.ClippedImageImpl.DraggableTemplate' via deferred binding
[ERROR] Compiler returned false
I really don't know what to do. We checked nearly every setting/config-file in eclipse and tomcat. Its all the same. Has anyone an idea where to look? Maybe I'm looking in the wrong places. I appreciate any help you can give me.
Additional information (update):
When building the application with ant the gwt-compile runs without errors.
We use eclipse WITHOUT google plugins.
In dev mode the web application is started via tomcat7.
The super-dev-mode is invoked WITHIN the web application (in Servlet.init()). Therefor we had to add the gwt-dev jars into the classpath of the tomcat launcher.
Including new SuggestBox() anywhere into our gwt source code causes the gwt-compile-error on some machines. Without new SuggestBox() everything compiles everywhere.
I think it is a classpath or gwt-compile-sourcepath problem. But we see no differences on the different machines we use.
When building the application with ant the gwt-compile runs without errors.
1) So if you compare the way you compile it and the way ant compiles it you will see the root cause.
2) In case you don't see any difference or you don't know how Eclipse (or whatever you use) compiles your application try to compile it in this way (we may call it true pure dzen way without any eclipse, ant, maven or other third-party "helpers"):
java -cp gwt-dev.jar;gwt-user.jar;validation-api-1.0.0.GA.jar;validation-api-1.0.0.GA-sources.jar;any/other/lib.jar;path/to/your/module/source/code com.google.gwt.dev.Compiler moduleName
In case your .gwt.xml descriptor is located under com/your/gwt/module/MyModule.gwt.xml you should use com.your.gwt.module.MyModule as a moduleName
As you have not included any code it is hard to guess what could have gone wrong, but here are some possible reasons:
Zero-parameter constructors
This is the one that was mentioned the most in the articles I read (references included below) and seems to create exactly the issue you are having, but I have to admit that I do not know why that would happen just to some of your teammates (maybe it is just needed under certain VMs or something like that).
It might be a deferred binding issue (according to the compiler log you posted) and therefore you should check if all your POJO (plain old java object) classes have a zero-parameter constructor for deferred loading.
Failed to resolve class via deferred binding
Conflicting annotations
Maybe you have some annotations placed wrong, as mentioned here:
Deferred binding failed GWT using uibinder
Some annotations such as #UiConstructor and #UiFactory don't go well together and (even though they are not actually conflicting in this case) can cause similar problems.
References & More
Failed to create an instance of Service via deferred binding
http://www.sencha.com/forum/archive/index.php/t-170786.html?s=fb45a32ac52270e43026da25ff956840
http://samuelcheng.wordpress.com/2011/01/02/deferred-binding-failure-in-gwt/
Deferred binding failed
https://groups.google.com/forum/#!topic/google-web-toolkit/iHajUf7sjtE
If you are using Maven, you can easily do a javac with mvn compile, then you can run mvn gwt:compile. These nasty errors will go away.

How do I find and eliminate an unwanted entry in my Eclipse classpath?

Our source code repository has an Eclipse run configuration in .settings/Program.launch, a classpath configuration in .classpath, and a set of user libraries we were all directed to import months ago by the Eclipse expert who used to be in our office. The user library set includes a defined user library named JBoss6.0.0.Final that points to all or most of the jars inside of JBoss, and the Program.launch run configuration includes this JBoss6.0.0.Final user library.
I'm now getting a conflict from slf4j telling me I need to remove one of the slf4j binding jars in my classpath:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/workspace/project/core/lib/slf4j-log4j12-1.6.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/jboss-6.0.0.Final/client/slf4j-jboss-logging.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.Log4jLoggerFactory]
I understand why I'm getting this warning, and I want to fix the situation by taking slf4j-jboss-logging.jar out of the classpath for Program.launch . I went to Window -> Preferences -> Java -> Build Path -> User Libraries, I opened the JBoss6.0.0.Final user library, and I removed slf4j-jboss-logging.jar . But when I run, I still get the same warning.
What is including this jar in my classpath? I want to remove it.
I exported my user libraries to an XML file and searched through it and slf4j-jboss-logging.jar is not in there at all. I read the Project.launch file and it doesn't refer to this jar. The .classpath file does not reference this jar, but it does include the following line, which I think pulls in the JBoss6.0.0.Final user library:
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JBoss6.0.0.Final"/>
I looked at the classpath tab under the run configurations for Project.launch, and it appears to be showing everything defined by the .classpath file.
Where is this offending jar coming from in my classpath?
I'm running Eclipse Indigo.
Try using jboss-classloading.xml, this should allow you to isolate your jars from those in included in jboss.
See if this link helps.