编程语言
首页 > 编程语言> > java – 无法从Storm教程中运行风暴启动器拓扑

java – 无法从Storm教程中运行风暴启动器拓扑

作者:互联网

在遵循风暴启动器repo中的指南时,我无法实际运行任何拓扑 – 如ExclamationTopology.

mvn clean install -DskipTests = true成功运行,从顶级Storm repo执行,就像在storm-examples级别的mvn包一样.

当我尝试运行storm 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

我正在运行OS X,Java版本:

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.

有没有人对我为什么会收到此错误以及我的设置中应该更改的内容有任何想法?

完整错误输出:

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中删除范围行后,此错误消失了,但替换为:

线程“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上的命令行运行storm-starterexamples.我改为使用Maven建立一个新项目,在[this](https://github.com/mbonaci/mbo-storm/wiki/Storm-setup-in-Eclipse-with-Maven,-Git-and-GitHub)一般指南之后添加storm-core作为依赖项.然后,在Eclipse中,我能够从storm导入正确的包来做示例,例如ExclamationTopology.我使用相同的导入重写了该类(更改为导入backtype.storm.Config等).然后,正常运行该文件.

这个quick Maven指南也有帮助.

解决方法:

关于尼克的答案,要更准确一点.

在storm-starter / pom.xml中,依赖storm-core指定范围为“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”中,即只需删除范围标记,然后再次在storm-starter中运行mvn -DskipTests包.

标签:java,apache-storm
来源: https://codeday.me/bug/20190715/1465813.html