我是风暴的初学者。这是storm入门(book)中的一个示例。wordcounter示例。我在local中使用storm,当我使用maven运行这个示例时,我得到了这个错误。maven命令使用:
[knk@kinock Storm-Starter]$mvn exec:java -Dexec.mainClass="TopologyMain" -Dexec.args="src/main/resources/words.txt"
这就是错误
java.lang.NullPointerException: null
at spouts.WordReader.open(WordReader.java:62) ~[classes/:na]
at backtype.storm.daemon.executor$fn__3430$fn__3445.invoke(executor.clj:504) ~[storm-core-0.9.0.1.jar:na]
at backtype.storm.util$async_loop$fn__444.invoke(util.clj:401) ~[storm-core-0.9.0.1.jar:na]
at clojure.lang.AFn.run(AFn.java:24) [clojure-1.4.0.jar:na]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
5608 [Thread-22-word-reader] ERROR backtype.storm.daemon.executor -
java.lang.NullPointerException: null
at spouts.WordReader.open(WordReader.java:62) ~[classes/:na]
at backtype.storm.daemon.executor$fn__3430$fn__3445.invoke(executor.clj:504) ~ [storm-core-0.9.0.1.jar:na]
at backtype.storm.util$async_loop$fn__444.invoke(util.clj:401) ~[storm-core- 0.9.0.1.jar:na]
at clojure.lang.AFn.run(AFn.java:24) [clojure-1.4.0.jar:na]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
5610 [Thread-6] INFO backtype.storm.daemon.executor - Loading executor __system:[-1 -1]
5618 [Thread-6] INFO backtype.storm.daemon.task - Emitting: __system __system ["startup"]
5619 [Thread-6] INFO backtype.storm.daemon.executor - Loaded executor tasks __system: [-1 -1]
5624 [Thread-6] INFO backtype.storm.daemon.executor - Finished loading executor __system:[-1 -1]
5629 [Thread-24-__system] INFO backtype.storm.daemon.executor - Preparing bolt __system:(-1)
5638 [Thread-24-__system] INFO backtype.storm.daemon.executor - Prepared bolt __system:(-1)
5668 [Thread-6] INFO backtype.storm.daemon.executor - Loading executor __acker:[1 1]
5670 [Thread-6] INFO backtype.storm.daemon.task - Emitting: __acker __system ["startup"]
5671 [Thread-6] INFO backtype.storm.daemon.executor - Loaded executor tasks __acker:[1 1]
5672 [Thread-22-word-reader] INFO backtype.storm.util - Halting process: ("Worker died")
5678 [Thread-6] INFO backtype.storm.daemon.executor - Timeouts disabled for executor __acker:[1 1]
5679 [Thread-6] INFO backtype.storm.daemon.executor - Finished loading executor __acker: [1 1]
这是引发异常的代码块。。第62行标有注解。
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
try {
//this.collector = collector;
this.context = context;
this.fileReader = new FileReader(conf.get("wordsFile").toString());//exception is raised here. 62nd line
} catch (FileNotFoundException e){
throw new RuntimeException("Error reading file ["+conf.get("wordFile")+"]");
}
this.collector = collector;
}
提前谢谢。。
2条答案
按热度按时间cbeh67ev1#
最可能的原因可能是它无法读取
wordsFile
从Config
对象。。e、 如果你有FileReader(conf.get("wordsFile").toString());
如果你用conf.put("SomeOtherWordsFile", ..)
然后它将尝试查找文件路径位置(在spout's
打开方法)形成conf
通过搜索键wordsFile
实际上并不存在iyfjxgzm2#
[knk@kinock 风暴开始者]$mvnexec:java -dexec.mainclass=“拓扑主要”-dexec.args=“src/main/resources/words.txt”
在上面的命令中,应该给出文件的完整路径,否则java找不到路径。