在Flink on yarn上 出现java.lang.NoClassDefFoundError跟ClassNotFoundException
通常是因为代码没有所需的依赖,根据提示定位到出错的代码行
DataSource<String> textFile = env.readTextFile(input);
DataSet<Tuple2<String, Integer>> out = textFile.flatMap(new FlatMapFunction<String, Tuple2<String, Integer>>() {
@Override
public void flatMap(String s, Collector<Tuple2<String, Integer>> out) throws Exception {
String[] splits = s.split(" ");
for (String word: splits) {
out.collect(new Tuple2<String, Integer>(word, 1));
}
}
}).groupBy(0).sum(1);
我的代码报错的位置是flatmap位置,但看了依赖里已经引入,所以这应该是连锁反应造成的,然后就用笨方法一个一个兑依赖,发现少了flink-client这个依赖
<!-- https://mvnrepository.com/artifact/org.apache.flink/flink-clients -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_2.11</artifactId>
<version>1.6.1</version>
</dependency>
加上重新运行就没事了,有遇到相同问题解决不了的,请留言,咱们一块解决