【问题标题】:Error occurs - "Could not find or load main class ", when run a topology on Storm official docker 1.2.1在 Storm 官方 docker 1.2.1 上运行拓扑时出现错误 - “找不到或加载主类”
【发布时间】:2018-03-05 04:15:40
【问题描述】:

我从 Docker Hub 中为 Storm 1.2.1 提取了最新的 docker 镜像。并根据项目下的README文档将Storm源代码1.2.1的storm-starter示例项目打包,并将包重命名为“topology.jar”。但是当我将 jar 文件提交到 Storm docker 时,使用

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

发生错误:

运行:/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
错误:无法找到或加载主类 org.apache.storm.starter.ExclamationTopology

我在与 ExclamationTopology 相同的包下添加了一个 HelloWorld 类,它只打印“Hello world!”在 main 方法中:

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

  • 类路径在发生错误时打印如上,跟在-cp 关键字后面。并且storm-starter的项目结构和Github官方的master分支一样。此外,HelloWorld 类与 ExclamationTopology 共享同一个包,即org.apache.storm.starter。你可以参考这里的源代码storm-starter

【问题讨论】:

  • 我们需要更多关于 topology.jar 中的清单文件、该 jar 中的类路径和主类的信息,以及有关目录结构的更多上下文。

标签: java maven docker runtime-error apache-storm


【解决方案1】:

终于,我明白了。 Storm 1.2.1 的 Docker Hub 上的官方 docker 镜像缺少名为 ConfigurableTopology 的类。从storm-client复制它作为本地的,然后重新编译包。即可提交成功。

【讨论】:

  • 我遇到了类似的问题,你能详细解释一下吗
猜你喜欢
  • 2016-09-11
  • 1970-01-01
  • 1970-01-01
  • 2016-04-16
  • 2015-08-06
  • 2015-06-12
  • 1970-01-01
  • 2019-05-01
  • 1970-01-01
相关资源
最近更新 更多