将flink从1.10升级到1.11,遇到错误 "no executorfactory found to execute the application"

c6ubokkw  于 2021-03-24  发布在  Flink
关注(0)|答案(3)|浏览(1120)
java.lang.IllegalStateException: No ExecutorFactory found to execute the application.
    at org.apache.flink.core.execution.DefaultExecutorServiceLoader.getExecutorFactory(DefaultExecutorServiceLoader.java:84)
    at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.executeAsync(StreamExecutionEnvironment.java:1803)
    at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1713)
    at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.execute(LocalStreamEnvironment.java:74)
    at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1699)
    at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1681)
    at com.cep.StaticAlarmGenerationEntryTest.main(StaticAlarmGenerationEntryTest.java:149)

我把flink从1.10升级到1.11后遇到的错误,我的id是eclipse。我试着添加artifactid:flink-clients_${scala.binary.version},但仍然失败。

mkshixfv

mkshixfv1#

我找到了为什么当我添加依赖flink-clients时发生错误的原因,我把flink从1.10升级到1.11,只是编辑了flink的版本,但没有改变scala的版本。
使用mvn archetype:generate -DarchetypeGroupId=org.apache.flink -DarchetypeArtifactId=flink-quickstart-java -DarchetypeVersion=1.11.0这个命令来生成新的项目。
你会发现pom.xml中已经添加了 "flink-clinets"。

ftf50wuq

ftf50wuq2#

当我把flink的工作打包到一个阴影的jar中时,我遇到了这个问题。当阴影时,如果在多个jar中存在同名的文件,它会在解压每个jar到新的阴影jar中时覆盖这个文件。
flink使用META-INF/services/org.apache.flink.core.execution.PipelineExecutorFactory文件来发现不同的执行工厂,而这个文件存在于多个jar中,每个jar都有不同的内容。
为了解决这个问题,我不得不告诉maven-shade插件,当它遇到这些文件时,就把它们合并在一起,这就为我解决了这个问题。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <shadedArtifactAttached>true</shadedArtifactAttached>
                <shadedClassifierName>job</shadedClassifierName>
                <transformers>
                    <!-- add this to combine the PipelineExecutorFactory files into one -->
                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/services/org.apache.flink.core.execution.PipelineExecutorFactory</resource>
                    </transformer>
                </transformers>
...
h7wcgrx3

h7wcgrx33#

参见1.11版本说明,现在你必须在flink-clients上添加一个明确的依赖关系。

相关问题