[英]Apache Storm: SLF4J: Class path contains multiple SLF4J bindings
我正在研究样本拓扑(一个喷口螺栓),但是当我使用命令行运行Storm项目时:
风暴jar目标/连接器-0.0.1-SNAPSHOT-jar-with-dependencies.jar拓扑.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.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
我的pom文件配置 :
<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>
我尝试了许多在Internet上找到的解决方案,但没有结果。 您对问题的根源有任何想法吗?
您将在这里找到解决方案: http : //www.slf4j.org/codes.html#multiple_bindings
将排除项添加到可能引起冲突的(pom.xml)依赖项中。
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.xx</version>
</exclusion>
</exclusions>
SLF4J多重绑定导致出现警告消息,但是您的程序将继续运行。 您看到的异常原因在堆栈跟踪中:
引起原因:java.lang.RuntimeException:java.io.IOException:找到多个defaults.yaml资源。 您可能将Storm jar与拓扑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]
消除jar中重复的defaults.yaml
。
我通过添加解决了这个问题:
<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>
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.