flink程序本地运行:No ExecutorFactory found to execute the application

1.问题描述

在idea中运行flink job程序出现如下错误:

Exception in thread "main" java.lang.IllegalStateException: No ExecutorFactory found to execute the application.

at org.apache.flink.core.execution.DefaultExecutorServiceLoader.getExecutorFactory(DefaultExecutorServiceLoader.java:88)

at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.executeAsync(StreamExecutionEnvironment.java:2085)

at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1983)

at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.execute(LocalStreamEnvironment.java:68)

at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1969)

at test.ReadTextDemo.main(ReadTextDemo.java:19)

2.问题分析

程序代码如下;

XML 复制代码
<dependencies>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-streaming-java</artifactId>
            <version>${flink.version}</version>
        </dependency>


        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.12</version>
        </dependency>
</dependencies>
java 复制代码
package test;

import org.apache.flink.api.java.io.TextInputFormat;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Description
 * @Author XXX
 * @Date 2024/5/23
 * @Version 1.0
 */
public class ReadTextDemo {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        TextInputFormat textInputFormat = new TextInputFormat(null);
        DataStreamSource<String> source = env.readFile(textInputFormat, "D:\\datatest\\readtext.txt");
        source.print();
        env.execute("readText test");
    }
}

代码比较简单,应该没问题,因此不用分析。

从报错信息可以看出,程序没有找到执行器工厂(ExecutorFactory)来执行应用程序中的任务,网上查询了下,出现该报错的原因有以下几个:

参考:no executorfactory found to execute the application_慕课手记

因为改flink 程序没有什么配置,因此可以排除1、3,那最有可能得原因就是2,缺少pom依赖,通过在flink官网可知:

所以应该是缺少flink-clients依赖,加上pom依赖,问题得到解决:

XML 复制代码
 <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-clients</artifactId>
            <version>${flink.version}</version>
</dependency>
相关推荐
yumgpkpm1 小时前
Doris 并入CMP7(类Cloudera CDP 7.3.1 404华为鲲鹏ARM版)的方案和实施源代码
大数据·oracle·sqlite·sqoop·milvus·cloudera
yumgpkpm1 小时前
Doris在CMP7(类Cloudera CDP 7 404版华为Kunpeng)启用 Kerberos部署Doris
大数据·hive·hadoop·python·oracle·flink·cloudera
YangYang9YangYan1 小时前
高职大数据技术专业学习与发展指南
大数据·人工智能·学习·数据分析
汤姆yu1 小时前
基于大数据的天气分析与应用系统
大数据
悦光阴2 小时前
SQL Server 并发控制:Fabric Warehouse只支持快照隔离
大数据·运维·数据库·fabric
DolphinScheduler社区2 小时前
Apache DolphinScheduler 3.3.2 正式发布!性能与稳定性有重要更新
大数据·开源·apache·任务调度·海豚调度·发版
SeaTunnel2 小时前
Apache SeaTunnel 支持 Metalake 开发了!避免任务配置敏感信息暴露
大数据·开源·apache·个人开发·数据集成·seatunnel·看开源之夏
飞雁科技3 小时前
CRM客户管理系统定制开发:如何精准满足企业需求并提升效率?
大数据·运维·人工智能·devops·驻场开发
飞雁科技3 小时前
上位机软件定制开发技巧:如何打造专属工业解决方案?
大数据·人工智能·软件开发·devops·驻场开发
leafff1234 小时前
AI研究:大语言模型(LLMs)需要怎样的硬件算力
大数据·人工智能·语言模型