Search code examples
javaapache-storm

Unable to run a storm-starter topology from the Storm tutorial


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 ran successfully, executed from the top level Storm repo, as did mvn package at the storm-examples level.

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

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 version 3.3.9.

Does anyone have any ideas on why I'm getting this error and what I should change in my setup?

Full error output:

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

Edit:

After following the suggestions in the answers below of removing the scope line from the pom.xml, this error was gone, but replaced by:

Exception in thread "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]

Final Edit:

For any future googler, I ended up not getting the storm-starterexamples 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.

This quick Maven guide helps too.


Solution

  • To be little bit more precise with regard to Nick's answer.

    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>
    

    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.