【flink】报错整理 Could not instantiate the executor. Make sure a planner module is on the classpath

前言

  • Flink 版本 1.15.1
  • scala 版本 2.12

最近在学习 Flink, 在 IDEA中调试 Flink sql 代码时报错,报错内容如下:

Exception in thread "main" org.apache.flink.table.api.TableException: Could not instantiate the executor. Make sure a planner module is on the classpath
	at org.apache.flink.table.api.bridge.internal.AbstractStreamTableEnvironmentImpl.lookupExecutor(AbstractStreamTableEnvironmentImpl.java:108)
	at org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl.create(StreamTableEnvironmentImpl.java:100)
	at org.apache.flink.table.api.bridge.java.StreamTableEnvironment.create(StreamTableEnvironment.java:122)
	at org.apache.flink.table.api.bridge.java.StreamTableEnvironment.create(StreamTableEnvironment.java:94)
	at table.FlinkTableTest.main(FlinkTableTest.java:15)
Caused by: org.apache.flink.table.api.ValidationException: Multiple factories for identifier 'default' that implement 'org.apache.flink.table.delegation.ExecutorFactory' found in the classpath.

Ambiguous factory classes are:

org.apache.flink.table.planner.delegation.DefaultExecutorFactory
org.apache.flink.table.planner.loader.DelegateExecutorFactory
	at org.apache.flink.table.factories.FactoryUtil.discoverFactory(FactoryUtil.java:553)
	at org.apache.flink.table.api.bridge.internal.AbstractStreamTableEnvironmentImpl.lookupExecutor(AbstractStreamTableEnvironmentImpl.java:105)
	... 4 more

Process finished with exit code 1

POM 文件

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-table-planner_2.12</artifactId>
    <version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
  <artifactId>flink-table-planner-loader</artifactId>
  <version>${flink.version}</version>
</dependency>

问题原因

我们项目pom.xml 文件里面配置了两个解析器,这两个解析器不能同时并存,这里我们去掉 flink-table-planner_2.12 这个即可。

从 Flink 1.15 开始,发行版包含两个规划器:

  • flink-table-planner_2.12-1.15.1.jar, in /opt, 包含查询规划器
  • flink-table-planner-loader-1.15.1.jar,默认加载/lib,包含隐藏在隔离类路径后面的查询计划器

注意: 两个规划器不能同时存在于类路径中。如果将它们都加载到/lib表作业中,则会失败。

问题解决!
参考:https://nightlies.apache.org/flink/flink-docs-release-1.15/docs/dev/configuration/advanced/

posted @ 2022-11-10 19:24  彬在俊  阅读(1243)  评论(0编辑  收藏  举报