首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Flink:在jar文件中找不到程序的入口点类

Flink:在jar文件中找不到程序的入口点类
EN

Stack Overflow用户
提问于 2020-12-23 10:00:58
回答 1查看 1.2K关注 0票数 2

我正在尝试将Flink stateful函数部署为flink jar,并遵循了here的说明。然而,我得到的错误是,即使我在pom中添加了依赖项,程序入口点类也没有在jar中找到。

运行:

代码语言:javascript
复制
bin/flink run -c org.apache.flink.statefun.flink.core.StatefulFunctionsJob flink-statefun/statefun-examples/statefun-greeter-example/target/statefun-greeter-example-2.3-SNAPSHOT.jar

产生以下错误:

代码语言:javascript
复制
org.apache.flink.client.program.ProgramInvocationException: The program's entry point class 'org.apache.flink.statefun.flink.core.StatefulFunctionsJob' was not found in the jar file.
    at org.apache.flink.client.program.PackagedProgram.loadMainClass(PackagedProgram.java:389)
    at org.apache.flink.client.program.PackagedProgram.<init>(PackagedProgram.java:139)
    at org.apache.flink.client.program.PackagedProgram.<init>(PackagedProgram.java:61)
    at org.apache.flink.client.program.PackagedProgram$Builder.build(PackagedProgram.java:557)
    at org.apache.flink.client.cli.CliFrontend.buildProgram(CliFrontend.java:726)
    at org.apache.flink.client.cli.CliFrontend.getPackagedProgram(CliFrontend.java:242)
    at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:223)
    at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:916)
    at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:992)
    at org.apache.flink.runtime.security.contexts.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:30)
    at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:992)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.statefun.flink.core.StatefulFunctionsJob
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at org.apache.flink.util.FlinkUserCodeClassLoader.loadClassWithoutExceptionHandling(FlinkUserCodeClassLoader.java:61)
    at org.apache.flink.util.ChildFirstClassLoader.loadClassWithoutExceptionHandling(ChildFirstClassLoader.java:65)
    at org.apache.flink.util.FlinkUserCodeClassLoader.loadClass(FlinkUserCodeClassLoader.java:48)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.flink.client.program.PackagedProgram.loadMainClass(PackagedProgram.java:387)
    ... 10 more

这是我的pom.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>statefun-examples</artifactId>
        <groupId>org.apache.flink</groupId>
        <version>2.3-SNAPSHOT</version>
        <relativePath>..</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>statefun-greeter-example</artifactId>

    <dependencies>
        
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>statefun-sdk</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>statefun-kafka-io</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>statefun-flink-core</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <!-- The following exclusion is needed since this artifacts pulls two different versions
                     of slf4j, and thus failing the maven convergence plugging.
                 -->
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.protobuf</groupId>
                    <artifactId>protobuf-java</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>statefun-flink-distribution</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <!-- The following exclusion is needed since this artifacts pulls two different versions
                     of slf4j, and thus failing the maven convergence plugging.
                 -->
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.protobuf</groupId>
                    <artifactId>protobuf-java</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.8.0</version>
        </dependency>
        
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.os72</groupId>
                <artifactId>protoc-jar-maven-plugin</artifactId>
                <version>${protoc-jar-maven-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <excludePackageNames>org.apache.flink.statefun.examples.greeter.generated</excludePackageNames>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
</project>

pom文件的原始版本可以在here中找到。似乎添加statefun-flink-distribution的额外依赖项没有任何效果。有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2020-12-27 04:29:10

提交Flink作业时,还需要提供该作业的依赖项。在本例中是数据流sdk jar。您可以创建一个带有依赖项和shade plugin的jar。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65418126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档