Search code examples
javamavendockerruntime-errorapache-storm

Error occurs - "Could not find or load main class ", when run a topology on Storm official docker 1.2.1


I pulled the latest docker image from Docker Hub for Storm 1.2.1. And packaged the storm-starter example project from Storm source code 1.2.1 according to the README documentation under the project, and renamed the package as "topology.jar". But when I submitted the jar file into Storm docker with

$ docker run -it -v $(pwd)/topology.jar:/topology.jar storm storm jar /topology.jar org.apache.storm.starter.ExclamationTopology,

the error occurred:

Running: /usr/lib/jvm/java-1.8-openjdk/jre/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/apache-storm-1.2.1 -Dstorm.log.dir=/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /apache-storm-1.2.1/:/apache-storm-1.2.1/lib/:/apache-storm-1.2.1/extlib/*:/topology.jar:/conf:/apache-storm-1.2.1/bin -Dstorm.jar=/topology.jar -Dstorm.dependency.jars= -Dstorm.dependency.artifacts={} org.apache.storm.starter.ExclamationTopology
Error: Could not find or load main class org.apache.storm.starter.ExclamationTopology

And I added a HelloWorld class under the same package as the ExclamationTopology is which just print "Hello world!" in the main method:

public static void main (String[] args) { System.out.println("Hello world!"); } When I submit this new package with $ docker run -it -v $(pwd)/topology.jar:/topology.jar storm storm jar /topology.jar org.apache.storm.starter.HelloWorld, it printed "Hello world!" as expected.

So what is the problem? Any help is appreciated.

PS.

  • /META-INFO/MANIFEST.MF in the topology.jar

    Manifest-Version: 1.0
    Implementation-Title: storm-starter
    Implementation-Version: 2.0.0-SNAPSHOT
    Archiver-Version: Plexus Archiver
    Built-By: leo
    Specification-Vendor: The Apache Software Foundation
    Specification-Title: storm-starter
    Implementation-Vendor-Id: org.apache.storm
    Implementation-Vendor: The Apache Software Foundation
    Created-By: Apache Maven 3.3.9
    Build-Jdk: 1.8.0_121
    Specification-Version: 2.0
    Implementation-URL: http://storm.apache.org/examples/storm-starter
    
  • When executed as jar -tvf topology.jar | grep ExclamationTopology. The console printed

2060 Mon Mar 05 11:40:08 CST 2018 org/apache/storm/starter/ExclamationTopology.class 2242 Mon Mar 05 11:40:08 CST 2018 org/apache/storm/starter/ExclamationTopology$ExclamationBolt.class

  • classpath is printed as above when the error occurred which follow the -cp keyword. And project structure of storm-starter is the same as the official master branch in Github. Besides, HelloWorld class shares the same package with ExclamationTopology which is org.apache.storm.starter. You can refer the source code here storm-starter.

Solution

  • Finally, I got it. The official docker image on Docker Hub for Storm 1.2.1 misses the class called ConfigurableTopology. Copy it from storm-client as the local one, then recompile the package. You can submit it successfully.