当前位置:   article > 正文

flink程序本地运行:No ExecutorFactory found to execute the application_flink no executorfactory found to execute the appl

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.问题分析

        程序代码如下;

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.apache.flink</groupId>
  4. <artifactId>flink-streaming-java</artifactId>
  5. <version>${flink.version}</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>mysql</groupId>
  9. <artifactId>mysql-connector-java</artifactId>
  10. <version>5.1.12</version>
  11. </dependency>
  12. </dependencies>
  1. package test;
  2. import org.apache.flink.api.java.io.TextInputFormat;
  3. import org.apache.flink.streaming.api.datastream.DataStreamSource;
  4. import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
  5. /**
  6. * @Description
  7. * @Author XXX
  8. * @Date 2024/5/23
  9. * @Version 1.0
  10. */
  11. public class ReadTextDemo {
  12. public static void main(String[] args) throws Exception {
  13. StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  14. TextInputFormat textInputFormat = new TextInputFormat(null);
  15. DataStreamSource<String> source = env.readFile(textInputFormat, "D:\\datatest\\readtext.txt");
  16. source.print();
  17. env.execute("readText test");
  18. }
  19. }

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

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

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

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

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

  1. <dependency>
  2. <groupId>org.apache.flink</groupId>
  3. <artifactId>flink-clients</artifactId>
  4. <version>${flink.version}</version>
  5. </dependency>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/821969
推荐阅读
相关标签
  

闽ICP备14008679号