[英]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.