You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@storm.apache.org by "Stig Rohde Døssing (JIRA)" <ji...@apache.org> on 2017/07/14 19:47:00 UTC

[jira] [Commented] (STORM-2382) log4j and slf4j conflicting libraries issue

    [ https://issues.apache.org/jira/browse/STORM-2382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16087915#comment-16087915 ] 

Stig Rohde Døssing commented on STORM-2382:
-------------------------------------------

Hi [~sreevaddi]. What you are seeing looks to be because there are multiple SLF4J bindings on the classpath. Here is a brief description of the jars involved:

* slf4j-api - Pretty self-explanatory, this is the SLF4J API classes. There's no implementation included in this.
* log4j-sfl4j-impl-2.1 - This is the Log4j 2 binding to SLF4J. This causes logs via the SLF4J API to go to a Log4j 2 logger. These loggers are configured via the log4j2/worker.xml configuration file.
* log4j-over-slf4j-1.6.6 - This is the Log4j 1 bridge to SLF4j. This causes logs on the Log4j 1 API to go to SLF4J. The result of this file along with log4j-slf4j-impl-2.1 is that both SLF4j API and Log4j 1 API logs will go to the Log4j 2 API.

Then there are the other two files, log4j-api-2.1 and log4j-core-2.1, which contain the Log4j 2 API and implementation. 

Given this line
{code}
SLF4J: Found binding in [jar:file:/tmp/356865dafc1a11e69341ecb1d7ac1510.jar!/org/slf4j/impl/StaticLoggerBinder.class]
{code}
it looks like your topology jar contains a different SLF4J binding from log4j-sfl4j-impl-2.1. You should ensure that your topology jar doesn't depend on the following (not a complete list):

* slf4j-log4j12 - This is the Log4j 1 SLF4J binding.
* slf4j-simple - This is a simple stdout binding for SLF4J

You may also want to check that your jar doesn't depend on log4j.jar, the Log4j1 implementation. log4j-over-slf4j-1.6.6 will provide classes that conflict with this.

Finally you should set the jars provided by Storm to "provided" scope in Maven. You don't want your jar to contain classes that are also on the Storm classpath. Someone else ran into this here, maybe it'll be helpful: https://stackoverflow.com/questions/36097878/exception-in-thread-main-java-lang-illegalaccesserror-in-storm-topology

> log4j and slf4j conflicting libraries issue
> -------------------------------------------
>
>                 Key: STORM-2382
>                 URL: https://issues.apache.org/jira/browse/STORM-2382
>             Project: Apache Storm
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>         Environment: centos 7.1, oracle jdk1.8
>            Reporter: Sree Vaddi
>            Priority: Blocker
>
> my project storm 1.0.1 job's dependencies (log4j & slf4j) conflict with apache&hdp storm 1.0.1 default libraries (STORM_HOME/lib) and is preventing submitting new storm job.
> * 1. shadow my storm job jar *
> I get the following error:
> {code:language=java}
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in [jar:file:/usr/hdp/2.5.0.0-1245/storm/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in [jar:file:/tmp/356865dafc1a11e69341ecb1d7ac1510.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.IllegalAccessError: tried to access method org.apache.logging.log4j.core.lookup.MapLookup.newMap(I)Ljava/util/HashMap; from class org.apache.logging.log4j.core.lookup.MainMapLookup
> 	at org.apache.logging.log4j.core.lookup.MainMapLookup.<clinit>(MainMapLookup.java:37)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> 	at org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:185)
> 	at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:65)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
> 	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
> 	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
> 	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
> 	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
> 	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
> 	at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
> 	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
> 	at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
> 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:277)
> 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
> 	at org.apache.storm.utils.LocalState.<clinit>(LocalState.java:45)
> 	at java.lang.Class.forName0(Native Method)
> 	at java.lang.Class.forName(Class.java:348)
> 	at clojure.lang.RT.classForName(RT.java:2154)
> 	at clojure.lang.RT.classForName(RT.java:2163)
> 	at org.apache.storm.config__init.__init7(Unknown Source)
> 	at org.apache.storm.config__init.<clinit>(Unknown Source)
> 	at java.lang.Class.forName0(Native Method)
> 	at java.lang.Class.forName(Class.java:348)
> 	at clojure.lang.RT.classForName(RT.java:2154)
> 	at clojure.lang.RT.classForName(RT.java:2163)
> 	at clojure.lang.RT.loadClassForName(RT.java:2182)
> 	at clojure.lang.RT.load(RT.java:436)
> 	at clojure.lang.RT.load(RT.java:412)
> 	at clojure.core$load$fn__5448.invoke(core.clj:5866)
> 	at clojure.core$load.doInvoke(core.clj:5865)
> 	at clojure.lang.RestFn.invoke(RestFn.java:408)
> 	at clojure.core$load_one.invoke(core.clj:5671)
> 	at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
> 	at clojure.core$load_lib.doInvoke(core.clj:5710)
> 	at clojure.lang.RestFn.applyTo(RestFn.java:142)
> 	at clojure.core$apply.invoke(core.clj:632)
> 	at clojure.core$load_libs.doInvoke(core.clj:5753)
> 	at clojure.lang.RestFn.applyTo(RestFn.java:137)
> 	at clojure.core$apply.invoke(core.clj:634)
> 	at clojure.core$use.doInvoke(core.clj:5843)
> 	at clojure.lang.RestFn.invoke(RestFn.java:408)
> 	at org.apache.storm.command.config_value$loading__5340__auto____12764.invoke(config_value.clj:16)
> 	at org.apache.storm.command.config_value__init.load(Unknown Source)
> 	at org.apache.storm.command.config_value__init.<clinit>(Unknown Source)
> 	at java.lang.Class.forName0(Native Method)
> 	at java.lang.Class.forName(Class.java:348)
> 	at clojure.lang.RT.classForName(RT.java:2154)
> 	at clojure.lang.RT.classForName(RT.java:2163)
> 	at clojure.lang.RT.loadClassForName(RT.java:2182)
> 	at clojure.lang.RT.load(RT.java:436)
> 	at clojure.lang.RT.load(RT.java:412)
> 	at clojure.core$load$fn__5448.invoke(core.clj:5866)
> 	at clojure.core$load.doInvoke(core.clj:5865)
> 	at clojure.lang.RestFn.invoke(RestFn.java:408)
> 	at clojure.lang.Var.invoke(Var.java:379)
> 	at org.apache.storm.command.config_value.<clinit>(Unknown Source)
> {code}
> * 2. upgrade STORM_HOME/lib *
> I get this warning.  looks like a racing condition (?)
> {code:language=java}
> log4j:WARN No appenders could be found for logger (org.apache.storm.utils.Utils).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
> log4j:WARN No appenders could be found for logger (org.apache.storm.utils.Utils).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)