slf4j-log4j jar required?


(Diptamay) #1

Hi

This is probably a silly question. But so far I have always used ES's http endpoint to do my searching. Now that I am trying to use the java api, I dropped in the elasticsearch-0.12.0.jar into my classpath and expected my tests to run which is just creating a TransportClient at the moment.

However, slf4j starts giving errors using Guice injection. Start of the error stack trace bloew is

[BF-INFO] Source Directory: '/Users/sanyal/Documents/workspace/mlbam/svn/cms/search/client/test/java'
[BF-INFO] Include: '/*'
[BF-INFO] Exclude: '
/CVS/'
[BF-INFO] Exclude: '
/.svn/**'
[javac] Compiling 1 source file to /Users/sanyal/Documents/workspace/mlbam/svn/cms/search/client/build/test/java/classes
[junit] Running com.bamnetworks.cms.search.test.ESClientTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167 sec
[junit] Testsuite: com.bamnetworks.cms.search.test.ESClientTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167 sec

[junit] ------------- Standard Error -----------------
[junit] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[junit] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[junit] ------------- ---------------- ---------------
[junit] Testcase: testGetESEndpoints(com.bamnetworks.cms.search.test.ESClientTest):	Caused an ERROR
[junit] Guice creation errors:

[junit] 1) Error injecting constructor, java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be successfully initialized. See also http://www.slf4j.org/codes.html#unsuccessfulInit
[junit]   at org.elasticsearch.common.network.NetworkService.<init>(NetworkService.java:63)
[junit]   while locating org.elasticsearch.common.network.NetworkService
[junit] Caused by: java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be successfully initialized. See also http://www.slf4j.org/codes.html#unsuccessfulInit
[junit] 	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:282)
[junit] 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248)
[junit] 	at org.elasticsearch.common.logging.slf4j.Slf4jESLoggerFactory.newInstance(Slf4jESLoggerFactory.java:32)
[junit] 	at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:60)
[junit] 	at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:142)
[junit] 	at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:105)

After dropping in the slf4j-log4j jar, which I downloaded separately, this starts working. I don't see any dependency of this in the ES maven poms or even in the ES distribution download itself.

Any idea what could be the issue here?

As a side note, do I need logging.yml and elasticsearch.yml in my classpath for the ES client to work properly.

Thanks
Diptamay


(system) #2