org.apache.flink.client.program.ProgramInitationException:由于链接失败,无法加载程序的入口点类

问题描述 投票:0回答:1

我正在尝试向我的 Apache Flink Web 仪表板 (localhost:8081) 提交基本的 Flink 作业。这是我的pom-

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.flink</groupId>
    <artifactId>kafkaconsumer</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <target.java.version>1.8</target.java.version>
    </properties>
    <dependencies>
     <dependency>
      <groupId>org.apache.flink</groupId>
      <artifactId>flink-clients</artifactId>
      <version>1.15.1</version>
      <scope>provided</scope>
    </dependency>
    </dependencies>

    <build>
    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <!-- Run shade goal on package phase -->
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <artifactSet>
                <excludes>
                  <exclude>org.apache.flink:flink-shaded-force-shading</exclude>
                  <exclude>org.slf4j:*</exclude>
                  <exclude>org.apache.logging.log4j:*</exclude>
                </excludes>
              </artifactSet>
              <filters>
                <filter>
                  <!-- Do not copy the signatures in the META-INF folder. Otherwise,
                    this might cause SecurityExceptions when using the JAR. -->
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
              <transformers>
                <transformer
                  implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                <transformer
                  implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass> com.flink.KafkaConsumer </mainClass>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    </build> 

    </project>

我的 jar 文件正在成功构建。这些是我罐子里的东西 -

META-INF/MANIFEST.MF
META-INF/
com/
com/flink/
com/flink/KafkaConsumer.class
com/flink/Main.class
META-INF/maven/
META-INF/maven/com.flink/
META-INF/maven/com.flink/kafkaconsumer/
META-INF/maven/com.flink/kafkaconsumer/pom.xml
META-INF/maven/com.flink/kafkaconsumer/pom.properties

将我的作业 jar 文件提交到 Apache Flink Dashboard 时,我收到服务器错误 -

org.apache.flink.client.program.ProgramInvocationException: The program's entry point class 'com.flink.KafkaConsumer' could not be loaded due to a linkage failure.
我哪里错了?请记住,我刚刚开始使用 Flink 并正在学习。

java apache-flink
1个回答
0
投票

我认为您的 pom.xml 中缺少依赖项。我只能看到

flink-clients
,但你至少需要
flink-streaming-java
阅读此处,如果你想使用 Kafka,则需要 kafka 连接器的依赖项。

  • 如果您想使用数据格式(avro、orc、parquet...),您需要一个依赖项。 更多这里
  • 如果您使用连接器(jdbc、kafka、nifi...)看这里
© www.soinside.com 2019 - 2024. All rights reserved.