Apache Flink: Cannot find compatible factory for specified execution.target (=local)

喜你入骨 提交于 2020-06-27 20:47:51

问题


I've decided to experiment with apache flink a bit. I decided to use scala console (or more precisely http://ammonite.io/) to read some stuff from csv file and print it locally... just to debug end experiments.

import $ivy.`org.apache.flink:flink-csv:1.10.0`
import $ivy.`org.apache.flink::flink-scala:1.10.0`

import org.apache.flink.api.scala._
import org.apache.flink.api.scala.extensions._

val env = ExecutionEnvironment.createLocalEnvironment()
val lines = env.readCsvFile[(String, String, String)]("/home/slovic/Dokumenty/test.csv")
lines.collect()
//java.lang.NullPointerException: Cannot find compatible factory for specified execution.target (=local)
//org.apache.flink.util.Preconditions.checkNotNull(Preconditions.java:104)
//org.apache.flink.api.java.ExecutionEnvironment.executeAsync(ExecutionEnvironment.java:937)
//org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:860)
//org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:844)
//org.apache.flink.api.scala.ExecutionEnvironment.execute(ExecutionEnvironment.scala:495)
//org.apache.flink.api.scala.DataSet.collect(DataSet.scala:739)
//ammonite.$sess.cmd24$.<init>(cmd24.sc:1)
//ammonite.$sess.cmd24$.<clinit>(cmd24.sc)

What I need to do to run this code locally? (tested with scala 2.11 & 2.12)

EDIT: SOLLUTION BY Piyush_Rana We need additional import:

import $ivy.`org.apache.flink::flink-streaming-scala:1.10.0`  //Piyush_Rana's advice. !!!FIX!!!

回答1:


I also got the same error and figured out that was missing one dependency -

val flinkVersion = "1.10.0"
"org.apache.flink" %% "flink-streaming-scala" % flinkVersion,

or in ammonite repl:

import $ivy.`org.apache.flink::flink-streaming-scala:1.10.0`



回答2:


You didnt execute the flink program .

Try to add execute command at the end.

 env.execute("unique name")


来源:https://stackoverflow.com/questions/60391499/apache-flink-cannot-find-compatible-factory-for-specified-execution-target-lo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!