当打包拓扑到集群中运行的时候,如果你得到了这么一个错误:
Error preparing HdfsBolt: No FileSystem for scheme: hdfs
原因在这里:
http://storm.apache.org/releases/0.10.0/storm-hdfs.html
大概是说,如果使用到hadoop client相关的,要使用maven-shade-plugin
插件来代替maven-assembly-plugin.
配置文件中应该这么写:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass></mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
打包的时候如果使用到了storm-core相关的,要在scope中注明provided:
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<scope>provided</scope>
<version>1.1.0</version>
</dependency>
否则在集群上提交的时候会抛异常:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/apache-storm-1.1.0/lib/log4j-slf4j-impl-2.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/Storm_1-1.0-SNAPSHOT.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__908.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: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____12276.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)
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:/usr/local/apache-storm-1.1.0/lib/storm-core-1.1.0.jar!/defaults.yaml, jar:file:/root/Storm_1-1.0-SNAPSHOT.jar!/defaults.yaml]
at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:383)
at org.apache.storm.utils.Utils.readDefaultConfig(Utils.java:427)
at org.apache.storm.utils.Utils.readStormConfig(Utils.java:463)
at org.apache.storm.utils.Utils.<clinit>(Utils.java:177)
... 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:/usr/local/apache-storm-1.1.0/lib/storm-core-1.1.0.jar!/defaults.yaml, jar:file:/root/Storm_1-1.0-SNAPSHOT.jar!/defaults.yaml]
at org.apache.storm.utils.Utils.getConfigFileInputStream(Utils.java:409)
at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:362)
... 42 more
Running: /usr/local/java/jdk1.8.0_131/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/usr/local/apache-storm-1.1.0 -Dstorm.log.dir=/usr/local/apache-storm-1.1.0/logs -Djava.library.path= -Dstorm.conf.file= -cp /usr/local/apache-storm-1.1.0/storm-wordcount-1.0-SNAPSHOT.jar:/usr/local/apache-storm-1.1.0/lib/storm-core-1.1.0.jar:/usr/local/apache-storm-1.1.0/lib/kryo-3.0.3.jar:/usr/local/apache-storm-1.1.0/lib/reflectasm-1.10.1.jar:/usr/local/apache-storm-1.1.0/lib/asm-5.0.3.jar:/usr/local/apache-storm-1.1.0/lib/minlog-1.3.0.jar:/usr/local/apache-storm-1.1.0/lib/objenesis-2.1.jar:/usr/local/apache-storm-1.1.0/lib/clojure-1.7.0.jar:/usr/local/apache-storm-1.1.0/lib/ring-cors-0.1.5.jar:/usr/local/apache-storm-1.1.0/lib/disruptor-3.3.2.jar:/usr/local/apache-storm-1.1.0/lib/log4j-api-2.8.jar:/usr/local/apache-storm-1.1.0/lib/log4j-core-2.8.jar:/usr/local/apache-storm-1.1.0/lib/log4j-slf4j-impl-2.8.jar:/usr/local/apache-storm-1.1.0/lib/slf4j-api-1.7.21.jar:/usr/local/apache-storm-1.1.0/lib/log4j-over-slf4j-1.6.6.jar:/usr/local/apache-storm-1.1.0/lib/servlet-api-2.5.jar:/usr/local/apache-storm-1.1.0/lib/storm-rename-hack-1.1.0.jar:/root/Storm_1-1.0-SNAPSHOT.jar:/usr/local/apache-storm-1.1.0/conf:/usr/local/apache-storm-1.1.0/bin -Dstorm.jar=/root/Storm_1-1.0-SNAPSHOT.jar -Dstorm.dependency.jars= -Dstorm.dependency.artifacts={} neu.ExclamationTopology example
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/apache-storm-1.1.0/lib/log4j-slf4j-impl-2.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/Storm_1-1.0-SNAPSHOT.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.TopologyBuilder.createTopology(TopologyBuilder.java:123)
at neu.ExclamationTopology.main(ExclamationTopology.java:73)
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:/usr/local/apache-storm-1.1.0/lib/storm-core-1.1.0.jar!/defaults.yaml, jar:file:/root/Storm_1-1.0-SNAPSHOT.jar!/defaults.yaml]
at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:383)
at org.apache.storm.utils.Utils.readDefaultConfig(Utils.java:427)
at org.apache.storm.utils.Utils.readStormConfig(Utils.java:463)
at org.apache.storm.utils.Utils.<clinit>(Utils.java:177)
... 2 more
Caused by: java.io.IOException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar. [jar:file:/usr/local/apache-storm-1.1.0/lib/storm-core-1.1.0.jar!/defaults.yaml, jar:file:/root/Storm_1-1.0-SNAPSHOT.jar!/defaults.yaml]
at org.apache.storm.utils.Utils.getConfigFileInputStream(Utils.java:409)
at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:362)
... 5 more