问题
I am a trying to integrate Storm with Kafka. I am running a Storm topology using KafkaSpout
. This is the basic word-count topology. I am using Apache Kafka as the source and storm for processing the data. While submitting the topology I am facing these issues. I am very new to Kafka and Storm. Please suggest me the changes I need to do in the following code.
This is my code:
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;
}
}
And this is the error I am getting:
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
回答1:
Looks like you miss the storm-core
jar in your classpath. Download and add it.
来源:https://stackoverflow.com/questions/30366277/exception-in-thread-main-java-lang-noclassdeffounderror-backtype-storm-spout