开发者社区> 问答> 正文

flink sql报错 Could not find any factory for identif

各位好,写了个demo,代码如下,在本地跑没有问题,提交到yarn session上报错: Caused by: org.apache.flink.table.api.ValidationException: Could not find any factory for identifier 'kafka' that implements 'org.apache.flink.table.factories.DynamicTableSourceFactory' in the classpath. 请问是什么原因导致的呢?

代码如下:


StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); EnvironmentSettings settings = EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build(); StreamTableEnvironment tenv = StreamTableEnvironment.create(env, settings);

tenv.executeSql("CREATE TABLE test_table (\n" + " id INT,\n" + " name STRING,\n" + " age INT,\n" + " create_at TIMESTAMP(3)\n" + ") WITH (\n" + " 'connector' = 'kafka',\n" + " 'topic' = 'test_json',\n" + " 'properties.bootstrap.servers' = 'localhost:9092',\n" + " 'properties.group.id' = 'testGroup',\n" + " 'format' = 'json',\n" + " 'scan.startup.mode' = 'latest-offset'\n" + ")"); Table table = tenv.sqlQuery("select * from test_table"); tenv.toRetractStream(table, Row.class).print(); env.execute("flink 1.11.0 demo");

pom 文件如下:

<scala.binary.version>2.11</scala.binary.version> <flink.version>1.11.0</flink.version> org.apache.flink

flink-table-planner-blink_${scala.binary.version} ${flink.version} org.apache.flink

flink-table-runtime-blink_${scala.binary.version} ${flink.version} org.apache.flink flink-json ${flink.version} org.apache.flink

flink-connector-kafka_${scala.binary.version} ${flink.version} org.apache.flink

flink-connector-kafka-0.11_${scala.binary.version} ${flink.version} org.apache.flink

flink-connector-kafka_${scala.binary.version} ${flink.version} org.apache.flink flink-core ${flink.version} org.apache.flink flink-clients_${scala.binary.version} ${flink.version} org.apache.flink flink-table-common ${flink.version} =============================================*来自志愿者整理的flink邮件归档

展开
收起
彗星halation 2021-12-07 16:05:13 1404 0
1 条回答
写回答
取消 提交回答
  • flink-connector-kafka_${scala.binary.version 和 flink-sql-connector-kafka_${scala.binary.version 只用加载一个应该就好了,前者的话是dataStream 或者 Table API 程序使用, 后者的话主要是对前者做了shade处理,方便用户在 SQL Client的环境中使用。理论上两个都应该ok的,还是同样的错误看起来是依赖没有正确的加载,不知道你的依赖的scope是如何制定的, 可以检查下yarn集群上Flink对应的lib下是否有对应的依赖了或者依赖的版本是否正确。

    [1] 中的话是有SQL Client JAR 的下载链接,就是 flink-sql-connector-kafka_${scala.binary.version jar 包的下载链接,你看一看下。

    *来自志愿者整理的flink邮件归档

    2021-12-07 16:25:09
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
SQL Server在电子商务中的应用与实践 立即下载
GeoMesa on Spark SQL 立即下载
原生SQL on Hadoop引擎- Apache HAWQ 2.x最新技术解密malili 立即下载