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

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

Related

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

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.

Spring Tool Suite (Eclipse): Update to 4.7 causes multiple SLF4J bindings

After I updated my STS based on Eclipse to 4.7, the build starts with a warning:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/A329865/OneDrive/Apps/sts-4.6.0.RELEASE/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:/C:/Users/A329865/OneDrive/Apps/sts-4.6.0.RELEASE/configuration/org.eclipse.osgi/5/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]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/A329865/OneDrive/Apps/sts-4.6.0.RELEASE/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:/C:/Users/A329865/OneDrive/Apps/sts-4.6.0.RELEASE/configuration/org.eclipse.osgi/5/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]
Even when I use a new STS 4.7 the same warning occurs.
I think the problem can be found in this line:
SLF4J: Found binding in [file:/C:/Users/A329865/OneDrive/Apps/sts-4.6.0.RELEASE/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
But I don't know how to deactivate it. It's not a plugin or jar-file. It seems to be a part of the osgi bundle.
Maybe my assumption is wrong, but can anybody help me?

Log4j warnings on linux

its my first day with Titan Database, I just wanna ask if I should worry about those warnings ?!
the link provided to help me solving this issue is quite complicated
Linux Ubuntu 14.04, and I did installed JDK 8, Titan 1.0.0 with Hadoop 1
Jan 17, 2016 5:04:20 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
\,,,/
(o o)
-----oOOo-(3)-oOOo-----
plugin activated: aurelius.titan
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/phoenix/Titan/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/phoenix/Titan/lib/logback-classic-1.1.2.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]
log4j:WARN No appenders could be found for logger (org.apache.hadoop.security.Groups).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.tinkergraph
gremlin>
You can ignore the log4j warnings.
In order to remove the warning - delete the file 'logback-classic-1.1.2.jar' from 'libs' folder.

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.

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.