我是暴风雨和intellij想法的初学者,当我将风暴启动器(apache-storm-0.9.5.zip)导入到intellij idea(14 CE OS)时,一切正常,但是当我运行" ExclamationTopology" ,问题如下:
Exception in thread "main" java.lang.NoClassDefFoundError: backtype/storm/topology/IRichSpout
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
Caused by: java.lang.ClassNotFoundException: backtype.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)
... 3 more
Process finished with exit code 1

这个界面来自storm-core,但这个maven托管的jar在我的库中 为什么会这样?..
答案 0 :(得分:8)
Strom已经在服务器端需要jar了。因此,如果查看pom.xml,您会发现类似于: https://github.com/apache/storm/blob/master/examples/storm-starter/pom.xml
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>${project.version}</version>
<!-- keep storm out of the jar-with-dependencies -->
<scope>provided</scope>
</dependency>
提供的范围仅适用于编译和测试类路径。因为它你的项目编译,但在运行时失败,例外:java.lang.NoClassDefFoundError。
请注意pom.xml中的范围行并更新maven依赖项以解决此问题。它应该看起来像:
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>${project.version}</version>
<!-- keep storm out of the jar-with-dependencies -->
<!-- <scope>provided</scope> -->
</dependency>