Storm提交Topology报错:Found multiple defaults.yaml resources.

Storm提交Topology运行方式分为本地和集群运行两种,其中集群运行需要将程序打包并把jar包复制到集群,通过以下方式执行:

bin/storm jar /opt/run/storm-demo-1.0-SNAPSHOT-jar-with-dependencies.jar org.mort.storm.kafka.KafkaTopologyBasic
bin/storm jar [jar包路径] [main所在类名]

不过有时程序运行报错提示如下:

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:/opt/run/storm-demo-1.0-SNAPSHOT-jar-with-dependencies.jar!/defaults.yaml, jar:file:/opt/module/apache-storm-1.2.3/lib/storm-core-1.2.3.jar!/defaults.yaml]
        at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:385)
        at org.apache.storm.utils.Utils.readDefaultConfig(Utils.java:429)
        at org.apache.storm.utils.Utils.readStormConfig(Utils.java:465)
        at org.apache.storm.utils.Utils.<clinit>(Utils.java:179)
        ... 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:/opt/run/storm-demo-1.0-SNAPSHOT-jar-with-dependencies.jar!/defaults.yaml, jar:file:/opt/module/apache-storm-1.2.3/lib/storm-core-1.2.3.jar!/defaults.yaml]
        at org.apache.storm.utils.Utils.getConfigFileInputStream(Utils.java:411)
        at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:364)
        ... 42 more

出现问题原因是storm-core下面也存在一个defaults.yaml文件,因此storm运行时报错冲突,因此修改Maven配置文件,添加scope属性并设为provided:

<dependency>
    <groupId>org.apache.storm</groupId>
    <artifactId>storm-core</artifactId>
    <version>1.2.3</version>
    <scope>provided</scope>
</dependency>

scope设置成provided表示容器或JDK已提供范围,表示该依赖包已经由目标容器(如tomcat)和JDK提供,只在编译的classpath中加载和使用,打包的时候不会包含在目标包中。

再次运行成功提交。

posted @ 2019-09-24 17:45  猫不夜行  阅读(1282)  评论(0编辑  收藏  举报