出现错误-"Could not find or load main class ",当运行 Storm 官方docker 1.2.1 上的一个拓扑
Error occurs - "Could not find or load main class ", when run a topology on Storm official docker 1.2.1
我从 Docker Hub for Storm 1.2.1 中提取了最新的 docker 图像。并根据项目下的README文档,将Storm源码1.2.1的storm-starter示例项目打包,并重命名为"topology.jar"。但是当我将 jar 文件提交到 Storm docker with
$ docker run -it -v $(pwd)/topology.jar:/topology.jar storm storm jar /topology.jar org.apache.storm.starter.ExclamationTopology
,
发生错误:
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
并且我在与 ExclamationTopology 相同的包下添加了一个 HelloWorld class,它只是在 main 方法中打印 "Hello world!":
public static void main (String[] args) {
System.out.println("Hello world!");
}
当我使用 $ docker run -it -v $(pwd)/topology.jar:/topology.jar storm storm jar /topology.jar org.apache.storm.starter.HelloWorld
提交这个新包时,它按预期打印了 "Hello world!"。
那么问题是什么?感谢任何帮助。
PS.
/META-INFO/MANIFEST.MF在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
- 执行时为
jar -tvf topology.jar | grep ExclamationTopology
。控制台打印
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在
-cp
关键字后面出现错误时如上打印。而storm-starter的项目结构和Github中的官方master分支是一样的。此外,HelloWorld class 与 ExclamationTopology 共享同一个包 org.apache.storm.starter
。你可以在这里参考源代码 storm-starter.
终于,我明白了。 Docker Hub for Storm 1.2.1 上的官方 docker 图片遗漏了名为 ConfigurableTopology
的 class。从 storm-client 复制它作为本地的,然后重新编译包。可以提交成功了。
我从 Docker Hub for Storm 1.2.1 中提取了最新的 docker 图像。并根据项目下的README文档,将Storm源码1.2.1的storm-starter示例项目打包,并重命名为"topology.jar"。但是当我将 jar 文件提交到 Storm docker with
$ docker run -it -v $(pwd)/topology.jar:/topology.jar storm storm jar /topology.jar org.apache.storm.starter.ExclamationTopology
,
发生错误:
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
并且我在与 ExclamationTopology 相同的包下添加了一个 HelloWorld class,它只是在 main 方法中打印 "Hello world!":
public static void main (String[] args) {
System.out.println("Hello world!");
}
当我使用 $ docker run -it -v $(pwd)/topology.jar:/topology.jar storm storm jar /topology.jar org.apache.storm.starter.HelloWorld
提交这个新包时,它按预期打印了 "Hello world!"。
那么问题是什么?感谢任何帮助。
PS.
/META-INFO/MANIFEST.MF在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
- 执行时为
jar -tvf topology.jar | grep ExclamationTopology
。控制台打印
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在
-cp
关键字后面出现错误时如上打印。而storm-starter的项目结构和Github中的官方master分支是一样的。此外,HelloWorld class 与 ExclamationTopology 共享同一个包org.apache.storm.starter
。你可以在这里参考源代码 storm-starter.
终于,我明白了。 Docker Hub for Storm 1.2.1 上的官方 docker 图片遗漏了名为 ConfigurableTopology
的 class。从 storm-client 复制它作为本地的,然后重新编译包。可以提交成功了。