简体   繁体   English

运行maven中的例外情况

[英]Exception in Running maven

I imported Example from how to use storm book 我从如何使用风暴书导入了例子

and when i run it i got this 当我运行它时,我得到了这个

INFO] An exception occured while executing the Java class. null 0

i used this command in Terminal 我在终端中使用了这个命令

mvn -f pom.xml compile exec:java -Dstorm.topology=TopologyMain

Code: 码:

import spouts.WordReader;
import backtype.storm.Config; 
import backtype.storm.LocalCluster;
import backtype.storm.topology.TopologyBuilder;
import backtype.storm.tuple.Fields;
import bolts.WordCounter; import bolts.WordNormalizer;
public class TopologyMain {

    public static void main(String[] args) throws InterruptedException {

        //Topology definition
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("word-reader",new WordReader());
        builder.setBolt("word-normalizer", new WordNormalizer()) .shuffleGrouping("word-reader");
        builder.setBolt("word-counter", new WordCounter(),1) .fieldsGrouping("word-normalizer", new Fields("word"));

        //Configuration
        Config conf = new Config(); conf.put("wordsFile", args[0]); conf.setDebug(false);
        //Topology run
        conf.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 1);
        LocalCluster cluster = new LocalCluster(); cluster.submitTopology("Getting-Started-Toplogie", conf, builder.createTopology());
        Thread.sleep(1000);
        cluster.shutdown();
     }
}

I also tried this: 我也试过这个:

mvn -f pom.xml clean install

then tried to use this 然后试着用这个

mvn exec:java -Dexec.mainClass="TopologyMain" -Dexec.args="src/main/resources/words.txt"

error here 错误在这里

[0] Inside the definition for plugin 'exec-maven-plugin' specify the following:

<configuration> ... <mainClass>VALUE</mainClass></configuration>

You're using the -D argument incorrectly. 您正在使用-D参数错误。 It should be instead: 它应该是:

mvn -f pom.xml compile exec:java -Dexec.mainClass=storm.topology.TopologyMain

This will specify the main class to execute. 这将指定要执行的主类。 It should be packaged with package storm.topology , which is not evident in the code you pasted. 它应该与package storm.topology ,这在您粘贴的代码中并不明显。


Also, I don't know why you're explicitly specifying your POM file. 此外,我不知道你为什么要明确指定你的POM文件。 You should create a pom.xml file in the project's root directory, and then you won't have to specify it on the command-line. 您应该在项目的根目录中创建一个pom.xml文件,然后您不必在命令行中指定它。 Ideally you should be typing, 理想情况下你应该打字,

mvn clean install

mvn exec:java -Dexec.mainClass="storm.topology.TopologyMain"

This will clean your project, compile it, install any dependencies, and then execute the project with TopologyMain as the entry point. 这将清理您的项目,编译它,安装任何依赖项,然后使用TopologyMain作为入口点执行项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Maven中运行硒测试时出现异常 - getting exception while running selenium test in maven 使用Maven运行码头时发生异常 - Exception occurs when running jetty with maven 从命令提示符或jenkins运行TestNG测试套件时出现Maven异常 - Maven exception while running the TestNG testsuite from command prompt or jenkins Maven 和 Class 运行时未发现异常。jar 文件 - Maven and Class not found exception while running .jar file jTDS - 运行 Maven 构建项目时没有合适的驱动程序异常 - jTDS - No Suitable Driver Exception when running a Maven built project 运行Maven2和Maven3 - Running Maven2 and Maven3 线程“ main”中的异常java.io.FileNotFoundException:使用java -cp命令运行Maven项目时 - Exception in thread “main” java.io.FileNotFoundException: when running maven project using java -cp command Jersey 2.0(Jax-RS 2.0)在Glassfish 3.1.2上运行时具有Maven抛出异常的Restfull Web服务吗? - Jersey 2.0 (Jax-RS 2.0) Restfull Webservice With Maven Throwing Exception While Running on Glassfish 3.1.2? 线程“主”java.lang.NoClassDefFoundError 中的异常:使用控制台运行时。 可能与 Maven 相关 - Exception in thread "main" java.lang.NoClassDefFoundError: when running with console. Possibly Maven-related 运行Maven项目时抛出不可解决的父POM异常 - Non-resolvable parent POM exception thrown while running maven project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM