h.zak
h.zak

Reputation: 1527

Apache Storm: SLF4J: Class path contains multiple SLF4J bindings

I working on a sample topology (one spout ont bolt), but When i run my storm project using command line :

storm jar target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.jar topology.ConnectorTopology

i get the error

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/share/storm/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/cloud/connector/target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.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.ExceptionInInitializerError
        at org.apache.storm.config$read_storm_config.invoke(config.clj:78)
        at org.apache.storm.config$fn__904.invoke(config.clj:100)
        at org.apache.storm.config__init.load(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:278)
        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____12655.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:278)
        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)
Caused by: java.lang.RuntimeException: java.io.IOException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar. [jar:file:/root/cloud/connector/target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/defaults.yaml, jar:file:/usr/share/storm/lib/storm-core-1.0.0.jar!/defaults.yaml]
        at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:307)
        at org.apache.storm.utils.Utils.readDefaultConfig(Utils.java:351)
        at org.apache.storm.utils.Utils.readStormConfig(Utils.java:387)
        at org.apache.storm.utils.Utils.<clinit>(Utils.java:119)
        ... 39 more
Caused by: java.io.IOException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar. [jar:file:/root/cloud/connector/target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/defaults.yaml, jar:file:/usr/share/storm/lib/storm-core-1.0.0.jar!/defaults.yaml]
        at org.apache.storm.utils.Utils.getConfigFileInputStream(Utils.java:333)
        at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:287)
        ... 42 more
Running: java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/usr/share/storm -Dstorm.log.dir=/usr/share/storm/logs -Djava.library.path= -Dstorm.conf.file= -cp /usr/share/storm/lib/disruptor-3.3.2.jar:/usr/share/storm/lib/storm-core-1.0.0.jar:/usr/share/storm/lib/slf4j-api-1.7.7.jar:/usr/share/storm/lib/objenesis-2.1.jar:/usr/share/storm/lib/log4j-core-2.1.jar:/usr/share/storm/lib/log4j-api-2.1.jar:/usr/share/storm/lib/reflectasm-1.10.1.jar:/usr/share/storm/lib/storm-rename-hack-1.0.0.jar:/usr/share/storm/lib/asm-5.0.3.jar:/usr/share/storm/lib/clojure-1.7.0.jar:/usr/share/storm/lib/log4j-over-slf4j-1.6.6.jar:/usr/share/storm/lib/servlet-api-2.5.jar:/usr/share/storm/lib/kryo-3.0.3.jar:/usr/share/storm/lib/minlog-1.3.0.jar:/usr/share/storm/lib/log4j-slf4j-impl-2.1.jar:target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.jar:/usr/share/storm/conf:/usr/share/storm/bin -Dstorm.jar=target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.jar topology.ConnectorTopology
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/share/storm/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/cloud/connector/target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.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.ExceptionInInitializerError
        at org.apache.storm.topology.BaseConfigurationDeclarer.<init>(BaseConfigurationDeclarer.java:26)
        at org.apache.storm.topology.TopologyBuilder$ConfigGetter.<init>(TopologyBuilder.java:406)
        at org.apache.storm.topology.TopologyBuilder$SpoutGetter.<init>(TopologyBuilder.java:423)
        at org.apache.storm.topology.TopologyBuilder.setSpout(TopologyBuilder.java:295)
        at org.apache.storm.topology.TopologyBuilder.setSpout(TopologyBuilder.java:278)
        at topology.ConnectorTopology.main(ConnectorTopology.java:34)
Caused by: java.lang.RuntimeException: java.io.IOException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar. [jar:file:/root/cloud/connector/target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/defaults.yaml, jar:file:/usr/share/storm/lib/storm-core-1.0.0.jar!/defaults.yaml]
        at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:307)
        at org.apache.storm.utils.Utils.readDefaultConfig(Utils.java:351)
        at org.apache.storm.utils.Utils.readStormConfig(Utils.java:387)
        at org.apache.storm.utils.Utils.<clinit>(Utils.java:119)
        ... 6 more
Caused by: java.io.IOException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar. [jar:file:/root/cloud/connector/target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/defaults.yaml, jar:file:/usr/share/storm/lib/storm-core-1.0.0.jar!/defaults.yaml]
        at org.apache.storm.utils.Utils.getConfigFileInputStream(Utils.java:333)
        at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:287)
        ... 9 more

my pom file configuration:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.project.connector</groupId>
        <artifactId>connector</artifactId>
        <version>0.0.1-SNAPSHOT</version>


<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>com.project.connector.ConnectorTopology</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>

    </plugin>
  </plugins>
</build>

        <dependencies>

                <dependency>
                        <groupId>com.rabbitmq</groupId>
                        <artifactId>amqp-client</artifactId>
                        <version>3.6.1</version>
                </dependency>

                <dependency>
                        <groupId>org.eclipse.paho</groupId>
                        <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
                        <version>1.0.2</version>
                </dependency>

                <dependency>
                        <groupId>org.codehaus.plexus</groupId>
                        <artifactId>plexus-utils</artifactId>
                        <version>3.0.22</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.storm</groupId>
                        <artifactId>storm-core</artifactId>
                        <version>1.0.0</version>
                </dependency>


        </dependencies>
</project>

I tried many solutions that I found on the internet, but no result. have you any idea about the source of the problem ?

Upvotes: 0

Views: 2505

Answers (3)

h.zak
h.zak

Reputation: 1527

I solved the problem by adding :

<scope>provided</scope>

and

<exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>logback-classic</groupId>
                    <artifactId>ch.qos.logback</artifactId>
                </exclusion>
            </exclusions>

Like this:

<dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <version>1.0.0</version>

            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>logback-classic</groupId>
                    <artifactId>ch.qos.logback</artifactId>
                </exclusion>
            </exclusions>

        </dependency>

Upvotes: 0

Jason Plurad
Jason Plurad

Reputation: 6792

The SLF4J multiple binding causes a warning message to appear, but your program would continue to run. The cause of the Exception you are seeing is in your stack trace:

Caused by: java.lang.RuntimeException: java.io.IOException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar. [jar:file:/root/cloud/connector/target/connector-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/defaults.yaml, jar:file:/usr/share/storm/lib/storm-core-1.0.0.jar!/defaults.yaml]

Eliminate the duplicate defaults.yaml in your jar.

Upvotes: 0

Stacey Morgan
Stacey Morgan

Reputation: 202

You will find a solution here: http://www.slf4j.org/codes.html#multiple_bindings

Add the exclusion in the dependencies (of pom.xml) that may be caused conflict.

<exclusions>
   <exclusion>  
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-log4j12</artifactId>
   <version>1.7.xx</version>
   </exclusion>
</exclusions> 

Upvotes: 1

Related Questions