本地编写storm作业代码时用的storm-core依赖要和集群上依赖一致,否则会报版本错误。
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
<groupId>com.jun.storm</groupId>
<artifactId>stormCount</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<!--<scope>provided </scope>-->
<version>1.2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<!-- 将依赖的其他jar(如 MyLocalFileSpout,MySplit等)也一起打包 -->
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<!-- 可以在这里指定运行的主类,这样在打包为jar包后就可以不用指定需要运行的类 -->
<mainClass>
stormCount.StormTopologyDriver
</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</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>
本地pom.xml文件中,storm-core的作用域要修改为provide,这样打包时不会被打进去,因为集群上已经有storm的依赖了,否则会引起依赖冲突。
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 backtype.storm.topology.TopologyBuilder.createTopology(TopologyBuilder.java:106)
at stormCount.StormTopologyDriver.main(StormTopologyDriver.java:26)
Caused by: java.lang.RuntimeException: Found multiple defaults.yaml resources. You're probably bundling the Storm
jars with your topology jar. [jar:file:/root/stormCount-1.0-SNAPSHOT-jar-with-dependencies.jar!/defaults.yaml,
jar:file:/itcast/apache-storm-1.2.2/lib/storm-core-1.2.2.jar!/defaults.yaml]
at backtype.storm.utils.Utils.findAndReadConfigFile(Utils.java:133)
at backtype.storm.utils.Utils.readDefaultConfig(Utils.java:160)
at backtype.storm.utils.Utils.readStormConfig(Utils.java:184)
at backtype.storm.utils.Utils.<clinit>(Utils.java:71)
... 2 more