无法运行 Storm 教程中的 Storm-starter 拓扑 [英] Unable to run a storm-starter topology from the Storm tutorial
问题描述
按照storm-starter 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 仓库执行,storm-examples
中的 mvn package
也是如此> 水平.
mvn clean install -DskipTests=true
ran successfully, executed from the top level Storm repo, as did mvn package
at the storm-examples
level.
当我尝试运行 storm jar target/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
中删除 scope
行后,此错误消失了,但替换为:
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]
最终编辑:
对于任何未来的 googler,我最终都没有在 LocalCluster
上通过命令行运行 storm-starter
示例.我改为使用 Maven 建立一个新项目,添加 storm-core
作为依赖项,遵循 [this] (https://github.com/mbonaci/mbo-storm/wiki/Storm-setup-in-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.
推荐答案
对 Nick 的回答更准确一点.
To be little bit more precise with regard to Nick's answer.
在storm-starter/pom.xml
中,依赖storm-core
被指定为范围provided":
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"的依赖项,即,只需删除 scope
标签,并再次运行 storm-starter
中的 mvn -DskipTests package
.
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 教程中的 Storm-starter 拓扑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!