java - 在 Storm 官方 docker 1.2.1 上运行拓扑时出现错误 - "Could not find or load main class "

标签 java maven docker runtime-error apache-storm

我从 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 ,

发生错误:

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 类,它只打印“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!”正如预期的那样。

那么问题出在哪里呢?如有任何帮助,我们将不胜感激。

附注。

  • topology.jar 中的/META-INFO/MANIFEST.MF

    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 .

最佳答案

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

关于java - 在 Storm 官方 docker 1.2.1 上运行拓扑时出现错误 - "Could not find or load main class ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49103407/

相关文章:

python-3.x - 如何使用 Boto3 向 AWS Batch 提交多个命令?

docker - Docker上的celery + rabbitmq

java - 磁盘读取操作执行速度非常慢 | Java流

java - 什么时候使用私有(private)构造函数有用?

java - 延迟初始化在 Spring MVC 3 中不起作用

xml - 在项目方面更改版本时,Eclipse Mars 中具有 M2E 不稳定配置的动态 Web 模块

java - 尝试从 jar 文件运行时,Spring Boot 应用程序不会运行

java - 如何使用 BundleContext 从包 list 中获取属性值?

java - 使用内部服务器使用 springmvc 和 eclipse 创建和调试应用程序

linux - 如何在 linux 中重定向 ps 命令以查看除/proc 之外的其他文件夹