gpt4 book ai didi

java - 运行就绪代码期间出现异常

转载 作者:太空宇宙 更新时间:2023-11-04 07:02:49 25 4
gpt4 key购买 nike

当我使用 Eclipse 导入编写的代码并将其作为 java 应用程序运行时,在运行就绪代码期间出现异常

这是错误...

Exception in thread "main" java.lang.NoSuchMethodError: backtype.storm.topology.TopologyBuilder.setBolt(Ljava/lang/String;Lbacktype/storm/    topology/IBasicBolt;Ljava/lang/Integer;)Lbacktype/storm/topology/BoltDeclarer; 
at TopologyMain.main(TopologyMain.java:18)

代码是

import spouts.WordReader; 
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.topology.TopologyBuilder;
import backtype.storm.tuple.Fields;
import bolts.WordCounter; import bolts.WordNormalizer;

public class TopologyMain { public static void main(String[] args) throws InterruptedException {
//Topology definition
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word-reader",new WordReader());
builder.setBolt("word-normalizer", new WordNormalizer()).shuffleGrouping("word-reader");
builder.setBolt("word-counter", new WordCounter(),1).fieldsGrouping("word- normalizer", new Fields("word"));

//Configuration
Config conf = new Config();
conf.put("wordsFile", args[0]); onf.setDebug(false);

//Topology run
conf.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 1);

LocalCluster cluster = new LocalCluster();
cluster.submitTopology("Getting-Started-Toplogie", conf, builder.createTopology());

Thread.sleep(1000); cluster.shutdown();
}
}

最佳答案

您可能已经修改了 TopologyBuilder 类或具有该类的 JAR。因为这种错误意味着类的编译时版本和运行时版本不相同,即 .class 在编译程序后已被某种方式修改。特别是,程序是使用 setBolt() 方法编译的,之后该方法在 .class 中被删除、重命名或修改

关于java - 运行就绪代码期间出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21843066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com