storm单机运行报错 ERROR backtype.storm.daemon.executor -

单机本地运行storm报错:

错误如下:

java.lang.NullPointerException: null
at test2.Spot2.nextTuple(Spot2.java:27) ~[classes/:na]
at backtype.storm.daemon.executor$fn__3371$fn__3386$fn__3415.invoke(executor.clj:572) ~[storm-core-0.9.6.jar:0.9.6]
at backtype.storm.util$async_loop$fn__460.invoke(util.clj:463) ~[storm-core-0.9.6.jar:0.9.6]
at clojure.lang.AFn.run(AFn.java:24) [clojure-1.5.1.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
11586 [Thread-22-spout] ERROR backtype.storm.daemon.executor - 
java.lang.NullPointerException: null
at test2.Spot2.nextTuple(Spot2.java:27) ~[classes/:na]
at backtype.storm.daemon.executor$fn__3371$fn__3386$fn__3415.invoke(executor.clj:572) ~[storm-core-0.9.6.jar:0.9.6]
at backtype.storm.util$async_loop$fn__460.invoke(util.clj:463) ~[storm-core-0.9.6.jar:0.9.6]
at clojure.lang.AFn.run(AFn.java:24) [clojure-1.5.1.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
11588 [Thread-27-__system] INFO backtype.storm.daemon.executor - Preparing bolt __system:(-1)
11591 [Thread-27-__system] INFO backtype.storm.daemon.executor - Prepared bolt __system:(-1)
11591 [Thread-20-__system] INFO backtype.storm.daemon.executor - Prepared bolt __system:(-1)
11594 [Thread-17-bolt] INFO backtype.storm.daemon.executor - Preparing bolt bolt:(3)
11595 [Thread-17-bolt] INFO backtype.storm.daemon.executor - Prepared bolt bolt:(3)
12040 [Thread-22-spout] ERROR backtype.storm.util - Halting process: ("Worker died")
java.lang.RuntimeException: ("Worker died")
at backtype.storm.util$exit_process_BANG_.doInvoke(util.clj:325) [storm-core-0.9.6.jar:0.9.6]
at clojure.lang.RestFn.invoke(RestFn.java:423) [clojure-1.5.1.jar:na]
at backtype.storm.daemon.worker$fn__4694$fn__4695.invoke(worker.clj:495) [storm-core-0.9.6.jar:0.9.6]
at backtype.storm.daemon.executor$mk_executor_data$fn__3272$fn__3273.invoke(executor.clj:241) [storm-core-0.9.6.jar:0.9.6]
at backtype.storm.util$async_loop$fn__460.invoke(util.clj:473) [storm-core-0.9.6.jar:0.9.6]
at clojure.lang.AFn.run(AFn.java:24) [clojure-1.5.1.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]

解决方法:

1、确认是否初始化collector

    public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
        this.collector = collector;
    }

2、确认是否是运行本地而不是集群的启动方式

集群方式:
StormSubmitter.submitTopology("wordcount", config, builder.createTopology()); 

本地方式:
LocalCluster local = new LocalCluster();
local.submitTopology("wordcount", conf, builder.createTopology());

 

open方法     

* 1、在任务集群的工作进程内被初始化,提供spout执行所需要的环境    

* 2、conf参数是这个spout的strom配置,提供给拓扑与这台主机上的集群配置一起合并

* 3、context主要用来获取这个任务在拓扑中的位置信息,包括该任务的id,该任务的组件id,输入和输出消息等 

* 4、collector是收集器,用于从spout发送元祖,收集器是线程安全的,应该作为这个spout对象的实例变量进行保存。 

 

我的错误是第一种,然后解决了

 

上一篇:大数据学习之Storm实时统计网站访问量案例35


下一篇:Java整合Storm使用中文分词