我有一个非常简单的拓扑结构:
builder.setSpout("StreamSpout", new StreamSpout(), 1);
builder.setBolt("Bolt", new TestBolt(), 1).shuffleGrouping("StreamSpout");
StreamSpout:
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
this.outputCollector = collector;
this.config = conf;
this.context = context;
}
public void nextTuple() {
this.outputCollector.emit(new Values("test"));
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("word"));
}
TestBolt:
public void execute(Tuple input, BasicOutputCollector collector) {
String word = input.getStringByField("word");
Logger.getLogger(this.getClass()).info(word);
}
我使用以下代码提交它:
conf.put(Config.NIMBUS_HOST, "W.X.Y.Z"); // Cluster's IP
conf.put(Config.NIMBUS_THRIFT_PORT,6627);
conf.put(Config.STORM_ZOOKEEPER_PORT,2181);
System.setProperty("storm.jar", "/home/.../{FileName}-SNAPSHOT.jar"); // Generated JAR file path
StormSubmitter submitter = new StormSubmitter();
submitter.submitTopology("de-linkS", conf, builder.createTopology());
但是每当我尝试将拓扑提交到我的集群时,我都会从工作日志文件中收到以下错误:
2015-04-06 21:36:03 b.s.d.worker [ERROR] Error on initialization of server mk-worker
java.lang.RuntimeException: java.lang.ClassNotFoundException: upa.pfe.storm.spouts.StreamSpout
at backtype.storm.utils.Utils.deserialize(Utils.java:95) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]
at backtype.storm.utils.Utils.getSetComponentObject(Utils.java:235) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]
at backtype.storm.daemon.task$get_task_object.invoke(task.clj:73) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]
...
但是,在将拓扑提交到本地cluser时,一切都运行良好。
我可能做错了什么想法?
由于
答案 0 :(得分:0)
所以我已经明白了!
问题似乎出现在项目的pom.xml文件中。 pom文件缺少必需的插件:
创建适合部署到群集的jar文件。
我能够使用以下pom文件打包和部署我的项目作为我的基础:https://github.com/apache/storm/blob/master/examples/storm-starter/pom.xml
一种愚蠢的方式进入残酷,但我希望这个线索可以帮助和洞察他人。
谢谢