gpt4 book ai didi

java - 线程 "main"java.lang.NoClassDefFoundError : backtype/storm/spout/MultiScheme 中的异常

转载 作者:行者123 更新时间:2023-11-30 08:51:54 25 4
gpt4 key购买 nike

我正在尝试将 Storm 与 Kafka 集成。我正在使用 KafkaSpout 运行 Storm 拓扑。这是基本的字数统计拓扑。我使用 Apache Kafka 作为源和 Storm 来处理数据。在提交拓扑时,我面临这些问题。我对 Kafka 和 Storm 很陌生。请建议我在以下代码中需要做的更改。

这是我的代码:

public class TopologyMain {

private static final String SENTENCE_SPOUT_ID = "kafka-sentence-spout";
private static final String WORD_NORMALIZER = "word-normalizer";
private static final String WORD_COUNTER = "word-counter";
private static final String TOPOLOGY_NAME = "kafka-word-count-topology";


public static void main(String[] args) throws InterruptedException, AlreadyAliveException, InvalidTopologyException {

int numSpoutExecutors = 1;

KafkaSpout kspout = buildKafkaSentenceSpout();
WordNormalizer normalizeBolt = new WordNormalizer();
WordCounter countBolt = new WordCounter();



//Topology definition
TopologyBuilder builder = new TopologyBuilder();

builder.setSpout(SENTENCE_SPOUT_ID, kspout, numSpoutExecutors);
builder.setBolt(WORD_NORMALIZER, new WordNormalizer()).shuffleGrouping(SENTENCE_SPOUT_ID);
builder.setBolt(WORD_COUNTER, new WordCounter(),1).fieldsGrouping(WORD_NORMALIZER, new Fields("word"));

//Configuration
Config conf = new Config();
//System.setProperty("storm.jar", "/home/raremile/.m2/repository/org/apache/storm/storm-core/0.9.3/storm-core-0.9.3.jar");
StormSubmitter.submitTopology(TOPOLOGY_NAME, conf, builder.createTopology());
conf.setDebug(false);

}

private static KafkaSpout buildKafkaSentenceSpout() {
String zkHostPort = "localhost:2181";
String topic = "sentences";

String zkRoot = "/acking-kafka-sentence-spout";
String zkSpoutId = "acking-sentence-spout";
ZkHosts zkHosts = new ZkHosts(zkHostPort);

SpoutConfig spoutCfg = new SpoutConfig(zkHosts, topic, zkRoot, zkSpoutId);
KafkaSpout kafkaSpout = new KafkaSpout(spoutCfg);
return kafkaSpout;
}
}

这是我得到的错误:

 Exception in thread "main" java.lang.NoClassDefFoundError: backtype/storm/spout/MultiScheme
at TopologyMain.buildKafkaSentenceSpout(TopologyMain.java:57)
at TopologyMain.main(TopologyMain.java:28)
Caused by: java.lang.ClassNotFoundException: backtype.storm.spout.MultiScheme
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 2 more

最佳答案

看起来您在类路径中错过了 storm-core jar。下载并添加它。

关于java - 线程 "main"java.lang.NoClassDefFoundError : backtype/storm/spout/MultiScheme 中的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30366277/

25 4 0
文章推荐: javascript - JSON 和 JavaScript 对象字面量中的有效名称之间的区别
文章推荐: javascript - 模糊背景 - Jquery/纯 CSS/图像?
文章推荐: javascript - 如何将多个 HTML 标签作为一个 javascript 变量
文章推荐: java - 如何从 List 中检索每个值