Couch DB lucene issue with slf4j - maven

I am trying to run couchdb lucene 2.2 on my machine and getting the following error:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
I am using maven to run it as per tutorial here: https://github.com/rnewson/couchdb-lucene
The pom file already has dependencies for this:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.35</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.35</version>
<scope>test</scope>
</dependency>
What can be the issue?

Related

StackOverflowError when including Spring Boot Actuator as a dependency within the project

I'm currently running a Spring Cloud Streams project in version Greenwich.SR2. Just tried to include the following dependency within the project.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
But as soon as I include it and run the project, the following pops up.
SLF4J: Found binding in [jar:file:/Users/sample/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.11.2/log4j-slf4j-impl-2.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/sample/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.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.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.StackOverflowError
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:108)
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:121)
at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
The set of dependencies regarding Spring Boot are the following ones.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
I already have .properties files for log4j2, is the Actuator dependency using older or any other version of the one which is already included?

Hive cli can not be run from brew installed hive

The brew installed hive appears to be a bit shy on maturity. First I had to manually edit the derby initailization script:
Unable to initialize hive with Derby from Brew install
Having done so .. when starting the cli it just hangs:
$hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/Cellar/hive/2.1.0/libexec/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/Cellar/hadoop/2.7.3/libexec/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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.apache.logging.slf4j.Log4jLoggerFactory]
Logging initialized using configuration in jar:file:/usr/local/Cellar/hive/2.1.0/libexec/lib/hive-common-2.1.0.jar!/hive-log4j2.properties Async: true
So having now run into two serious issues .. and not yet having seen hive actually work .. is there a known workaround or better alternative for brew [re]install hive ?
Update: I found another Q&A that solved the second portion of my question.
Configuring Hive to run in Local Mode
https://stackoverflow.com/a/33312359/1056563
You can try to increase the log level to see what is going on. The logging configuration seems to be inside a jar file but based on the source in git you can change the root logger level with system property hive.log.level. The default is INFO, so try running with -Dhive.log.level=DEBUG or even TRACE.
You can probably ignore the warning about multiple SLF4J bindings, but in case this worries you, the Log4j2 FAQ explains how to exclude the dependency on the old log4j slf4j binding.
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-project</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.8.2</version>
</dependency>
</dependencies>

Failed to load class “org.slf4j.impl.StaticLoggerBinder” error

I'm opening this post after I couldn't find a solution in the post:
Failed to load class "org.slf4j.impl.StaticLoggerBinder" error
I also opened a Maven project in IntelliJ and got the following error after choosing the option 'redeploy' in tomcat7 plugin:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J:
See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.
In the attached link, it was recommended to go to File-> Project Structure -> Artifacts and check for errors. This is what I see:
I also have the following dependencies in pom.xml file:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
Can you please help me finding the error?
Maybe there are two issues:
version mismatching of your dependencies
an issue when you deploy your application
For reproducing your error I've created this mini program:
package de.so;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DemoSlf4j
{
private static Logger logger = LoggerFactory.getLogger(DemoSlf4j.class);
public static void main(String[] args)
{
logger.error("Start ...");
}
}
with only these dependencies (same as you used) in pom.xml:
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
</dependencies>
I've got these messages:
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found
binding in
[jar:file:/D:/Maven-Repo/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/D:/Maven-Repo/org/slf4j/slf4j-simple/1.7.21/slf4j-simple-1.7.21.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.6
by your slf4j binding is not compatible with [1.6, 1.7] SLF4J: See
http://www.slf4j.org/codes.html#version_mismatch for further details.
log4j:WARN No appenders could be found for logger (de.so.DemoSlf4j).
log4j:WARN Please initialize the log4j system properly.
When I use these dependencies, everything is fine. Look at the versions!
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version> <!-- or use LATEST -->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version> <!-- or use LATEST -->
</dependency>
</dependencies>
If you are using org.slf4j:slf4j-log4j12:1.7.21 instead of slf4j-simple (what is more likely for production purposes), you'll get:
log4j:WARN No appenders could be found for logger (de.so.DemoSlf4j).
log4j:WARN Please initialize the log4j system properly. log4j:WARN See
http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
So do this:
look in your project dependencies if there are other artifacts which have cascading dependencies to logging frameworks (log4j, slf4f, ...).
check if your dependencies are proper deployed to your Tomcat. (.../WEB-INF/lib)
check the versions
Maybe you get cracked jar in your project ,check it in debug model detail,I had this problem too, when I build with debug model, I see warning of:
/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar ,so remove it ,and build it again. problem resolved.
You are providing a log api, and two different implementations, slf4j-log4j12 and slf4j-simple. I had the same issue, but in my case, it gave me an error message asking me to 'remove one' from class path.
You can try removing either slf4j-simple or slf4j-log4j12 from dependencies, clean and build project again.
I met with the same issue. I fixed it by adding the following dependencies to my POM.xml file:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
for the ${slf4j.version}, please assign the latest version number:
<properties>
...
<slf4j.version>1.7.30</slf4j.version>
</properties>

Elastic Search: java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager

Got below error when upgrade elastic search from 1.7 to 2.3.3
java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
at org.apache.log4j.Logger.getLogger(Logger.java:104)
at org.elasticsearch.common.logging.log4j.Log4jESLoggerFactory.newInstance(Log4jESLoggerFactory.java:38)
at org.elasticsearch.common.logging.ESLoggerFactory.newInstance(ESLoggerFactory.java:82)
at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:66)
at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:121)
at org.elasticsearch.common.settings.Settings.<clinit>(Settings.java:63)
I had few log4j jars and slf4j jars in classpath but Elastic search tries to load log4j logger by default if it is available in classpath. For some conflicts log4j did not work for me. So forced Elasticsearch to use slf4j logger while creating client.
ESLoggerFactory.setDefaultFactory(new Slf4jESLoggerFactory());
i resolved the same issue by adding below dependecies in POM.XML:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
</dependency>

Using Solrj 5.2.1 with Maven

I created a new Maven project with solrj dependency:
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>5.2.1</version>
</dependency>
It compiles correctly but if you try to use some solrj code the application crushes with the following exception:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.http.impl.client.CloseableHttpClient.<init>(CloseableHttpClient.java:58)
at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:287)
at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:128)
at org.apache.http.impl.client.SystemDefaultHttpClient.<init>(SystemDefaultHttpClient.java:116)
at org.apache.solr.client.solrj.impl.HttpClientUtil.createClient(HttpClientUtil.java:117)
at org.apache.solr.client.solrj.impl.CloudSolrClient.<init>(CloudSolrClient.java:189)
at Main.main(Main.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
Solrj depends on two generic logging libraries: SLF4J and Commons Logging. Each needs some kind of real implementation to work. Adding the following dependencies (Commons Logging to SLF4J redirection and simple console-based appender) to the pom.xml resolves the issue.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.7</version>
</dependency>

Resources