无法从Storm教程中运行风暴启动器拓扑 [英] Unable to run a storm-starter topology from the Storm tutorial
问题描述
遵循风暴入门指南 repo ,我无法实际运行任何拓扑 - 如 ExclamationTopology
。
When following the guide in the storm-starter repo, I'm unable to actually run any topology- like the ExclamationTopology
.
mvn clean install -DskipTests = true
成功运行,从顶级Storm repo执行, mvn package
在风暴中执行-examples
level。
mvn clean install -DskipTests=true
ran successfully, executed from the top level Storm repo, as did mvn package
at the storm-examples
level.
当我尝试运行风暴jar目标/ storm-starter-2.0.0-SNAPSHOT .jar org.apache.storm.starter.ExclamationTopology
,我收到错误:
When I try to run storm jar target/storm-starter-2.0.0-SNAPSHOT.jar org.apache.storm.starter.ExclamationTopology
, I get the error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/storm/topology/IRichSpout
我正在运行OS X,Java版本:
I'm running OS X, Java version:
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Maven版本3.3 .9。
Maven version 3.3.9.
有没有人知道为什么我会收到此错误以及我应该在设置中更改哪些内容?
Does anyone have any ideas on why I'm getting this error and what I should change in my setup?
完整错误输出:
Running:
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/Users/zachary/apache-storm-0.10.0 -Dstorm.log.dir=/Users/zachary/apache-storm-0.10.0/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /Users/zachary/apache-storm-0.10.0/lib/asm-4.0.jar:/Users/zachary/apache-storm-0.10.0/lib/clojure-1.6.0.jar:/Users/zachary/apache-storm-0.10.0/lib/disruptor-2.10.4.jar:/Users/zachary/apache-storm-0.10.0/lib/hadoop-auth-2.4.0.jar:/Users/zachary/apache-storm-0.10.0/lib/kryo-2.21.jar:/Users/zachary/apache-storm-0.10.0/lib/log4j-api-2.1.jar:/Users/zachary/apache-storm-0.10.0/lib/log4j-core-2.1.jar:/Users/zachary/apache-storm-0.10.0/lib/log4j-over-slf4j-1.6.6.jar:/Users/zachary/apache-storm-0.10.0/lib/log4j-slf4j-impl-2.1.jar:/Users/zachary/apache-storm-0.10.0/lib/minlog-1.2.jar:/Users/zachary/apache-storm-0.10.0/lib/reflectasm-1.07-shaded.jar:/Users/zachary/apache-storm-0.10.0/lib/servlet-api-2.5.jar:/Users/zachary/apache-storm-0.10.0/lib/slf4j-api-1.7.7.jar:/Users/zachary/apache-storm-0.10.0/lib/storm-core-0.10.0.jar:target/storm-starter-2.0.0-SNAPSHOT.jar:/Users/zachary/apache-storm-0.10.0/conf:/Users/zachary/apache-storm-0.10.0/bin -Dstorm.jar=target/storm-starter-2.0.0-SNAPSHOT.jar org.apache.storm.starter.ExclamationTopology
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/storm/topology/IRichSpout
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.storm.topology.IRichSpout
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
编辑:
按照以下答案中的建议删除后来自 pom.xml
的范围
行,此错误消失了,但替换为:
After following the suggestions in the answers below of removing the scope
line from the pom.xml
, this error was gone, but replaced by:
线程main中的异常java.lang.ExceptionInInitializerError
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:/Users/zachary/apache-storm-0.10.0/lib/storm-core-0.10.0.jar!/defaults.yaml, jar:file:/Users/zachary/storm/examples/storm-starter/target/storm-starter-2.0.0-SNAPSHOT.jar!/defaults.yaml]
最终编辑:
对于任何未来的Google员工,我最终都没有获得风暴启动器
在 LocalCluster
上通过命令行运行的示例。我改为用Maven设置一个新项目,在[this]之后添加 storm-core
作为依赖项( https://github.com/mbonaci/mbo-storm/wiki/Storm-设置在Eclipse-with-Maven,-Git-and-GitHub )一般指南。然后,在Eclipse中,我能够从 storm
导入正确的包来执行示例,例如 ExclamationTopology
。我使用相同的导入重写了该类(更改为 import backtype.storm.Config
等)。然后,运行该文件就行了。
For any future googler, I ended up not getting the storm-starter
examples running via the commandline on a LocalCluster
. I instead set up a new project with Maven, adding storm-core
as a dependency, following [this] (https://github.com/mbonaci/mbo-storm/wiki/Storm-setup-in-Eclipse-with-Maven,-Git-and-GitHub) general guide. Then, in Eclipse, I was able to import the right packages from storm
to do the examples, like ExclamationTopology
. I rewrote that class using the same imports (changed to import backtype.storm.Config
, etc). Then, running the file as is just works.
这快速 Maven指南也有帮助。
This quick Maven guide helps too.
推荐答案
要成为关于尼克的答案,更准确一点。
To be little bit more precise with regard to Nick's answer.
在 storm-starter / pom.xml
依赖 storm-core
指定范围为已提供:
In storm-starter/pom.xml
the dependency storm-core
is specified with scope "provided":
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>${project.version}</version>
<!--
Use "provided" scope to keep storm out of the jar-with-dependencies
For IntelliJ dev, intellij will load properly.
-->
<scope>${provided.scope}</scope>
</dependency>
如果您使用 LocalCluster
在本地运行,则需要包含 storm-core
作为依赖,默认范围为compile,即只需删除范围
标记,然后运行再次 mvn -DskipTests包
在 storm-starter
中。
If you run locally using LocalCluster
you need to include storm-core
as dependency with default scope "compile", ie, just remove the scope
tag, and run mvn -DskipTests package
in storm-starter
again.
这篇关于无法从Storm教程中运行风暴启动器拓扑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!