获取backtype.storm.generated.InvalidTopologyException:null。如果我评论调用setBolt它运行

时间:2015-05-05 04:27:40

标签: apache-storm

如果评论builder.setBolt然后它正确运行。请告诉我出错的地方

    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("words", new TestWordSpout(), 3);
    //Calling setBolt
    builder.setBolt("exc", new ExclaimBolt(),3)
    .allGrouping("words");

    Config conf = new Config();
    conf.setDebug(false);
    //conf.setNumWorkers(2);

    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("test", conf, builder.createTopology());

1 个答案:

答案 0 :(得分:1)

没有在Spout中声明输出字段。 声明它工作正常后。

代码示例(在你的螺栓类中):

@Override

public void declareOutputFields(OutputFieldsDeclarer declarer) {

    declarer.declare(new Fields("msg"));//based on u project

}