如何通过命令提示符运行Storm Topology类?

时间:2015-01-27 13:04:31

标签: batch-file apache-storm topology

我有一个主要方法的拓扑类。它启动zookeeper并在eclispe中运行右键单击运行作为java应用程序。但我正在尝试它能够运行我尝试过的批处理文件

java -classpath jar-with-classes-and-dependency.jar com.demo.Topology

但这给了我这样的例外。

Exception in thread "main" java.lang.NoClassDefFoundError:
backtype/storm/generated/AlreadyAliveException
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Caused by: java.lang.ClassNotFoundException:
backtype.storm.generated.AlreadyAliveException
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)

我认为这是缺少任何依赖。 请帮助您运行此拓扑类。

1 个答案:

答案 0 :(得分:2)

尝试像这样跑......

pathToStorm/bin/storm jar ./target/jar-with-classes-and-dependency.jar com.demo.Topology.

请记住,在执行此步骤之前,您应该构建jar。你可以通过运行来构建你的jar     您的pom.xml文件所在的风暴项目中的mvn clean install