IDEA可以正常运行,使用jar包启动后,就报下面的错误
2024-02-28 16:38:09.568 WARN 59419 --- [lt-dispatcher-4] .a.f.r.s.t.DefaultDelegationTokenManager : No tokens obtained so skipping notifications
2024-02-28 16:38:09.568 WARN 59419 --- [lt-dispatcher-4] .a.f.r.s.t.DefaultDelegationTokenManager : Tokens update task not started because either no tokens obtained or none of the tokens specified its renewal date
2024-02-28 16:38:09.569 INFO 59419 --- [ter-io-thread-4] o.a.f.r.h.n.e.EmbeddedLeaderService : Received confirmation of leadership for leader pekko://flink/user/rpc/resourcemanager_1 , session=5f111541-15bc-4d44-aab7-f393c1ffdcaf
2024-02-28 16:38:09.571 INFO 59419 --- [lt-dispatcher-4] o.a.f.runtime.taskexecutor.TaskExecutor : Connecting to ResourceManager pekko://flink/user/rpc/resourcemanager_1(aab7f393c1ffdcaf5f11154115bc4d44).
2024-02-28 16:38:09.571 INFO 59419 --- [ter-io-thread-1] o.a.f.r.h.n.e.EmbeddedLeaderService : Received confirmation of leadership for leader pekko://flink/user/rpc/dispatcher_2 , session=b7c356f2-b9ce-4254-90a1-0d13518c6883
2024-02-28 16:38:09.601 INFO 59419 --- [lt-dispatcher-8] o.a.f.runtime.taskexecutor.TaskExecutor : Resolved ResourceManager address, beginning registration
2024-02-28 16:38:09.608 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.r.StandaloneResourceManager : Registering TaskManager with ResourceID 9acc0233-57a4-4d8b-8c97-0e17008e0dca (pekko://flink/user/rpc/taskmanager_0) at ResourceManager
2024-02-28 16:38:09.610 INFO 59419 --- [lt-dispatcher-7] o.a.f.r.dispatcher.StandaloneDispatcher : Received JobGraph submission 'evp job' (bbc2959a1228d4782ade6888026503f1).
2024-02-28 16:38:09.610 INFO 59419 --- [lt-dispatcher-6] o.a.f.runtime.taskexecutor.TaskExecutor : Successful registration at resource manager pekko://flink/user/rpc/resourcemanager_1 under registration id 2e75d4e948fb7413bdd8ddaa65535673.
2024-02-28 16:38:09.611 INFO 59419 --- [lt-dispatcher-7] o.a.f.r.dispatcher.StandaloneDispatcher : Submitting job 'evp job' (bbc2959a1228d4782ade6888026503f1).
2024-02-28 16:38:09.612 INFO 59419 --- [lt-dispatcher-4] o.a.f.r.r.s.FineGrainedSlotManager : Registering task executor 9acc0233-57a4-4d8b-8c97-0e17008e0dca under 2e75d4e948fb7413bdd8ddaa65535673 at the slot manager.
2024-02-28 16:38:09.627 INFO 59419 --- [lt-dispatcher-7] o.a.f.r.h.n.e.EmbeddedLeaderService : Proposing leadership to the contender that is registered under component ID 'job-bbc2959a1228d4782ade6888026503f1'.
2024-02-28 16:38:09.628 INFO 59419 --- [ter-io-thread-2] a.f.r.j.JobMasterServiceLeadershipRunner : JobMasterServiceLeadershipRunner for job bbc2959a1228d4782ade6888026503f1 was granted leadership with leader id 624ca6ad-7a55-43ed-9668-28c7ce10c3b2. Creating new JobMasterServiceProcess.
2024-02-28 16:38:09.641 INFO 59419 --- [ger-io-thread-1] o.a.f.runtime.rpc.pekko.PekkoRpcService : Starting RPC endpoint for org.apache.flink.runtime.jobmaster.JobMaster at pekko://flink/user/rpc/jobmanager_3 .
2024-02-28 16:38:09.649 INFO 59419 --- [ger-io-thread-1] o.a.flink.runtime.jobmaster.JobMaster : Initializing job 'evp job' (bbc2959a1228d4782ade6888026503f1).
2024-02-28 16:38:09.691 INFO 59419 --- [lt-dispatcher-7] o.a.f.r.dispatcher.StandaloneDispatcher : Job bbc2959a1228d4782ade6888026503f1 reached terminal state FAILED.
org.apache.flink.runtime.client.JobInitializationException: Could not start the JobMaster.
at org.apache.flink.runtime.jobmaster.DefaultJobMasterServiceProcess.lambda$new$0(DefaultJobMasterServiceProcess.java:97)
at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:842)
Caused by: java.util.concurrent.CompletionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.flink.api.common.ExecutionConfig
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770)
... 3 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.flink.api.common.ExecutionConfig
at org.apache.flink.util.ExceptionUtils.rethrow(ExceptionUtils.java:321)
at org.apache.flink.util.function.FunctionUtils.lambda$uncheckedSupplier$4(FunctionUtils.java:114)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
... 3 more
Caused by: java.lang.ClassNotFoundException: org.apache.flink.api.common.ExecutionConfig
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at org.apache.flink.util.InstantiationUtil$ClassLoaderObjectInputStream.resolveClass(InstantiationUtil.java:78)
at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2045)
at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1909)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2235)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1744)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:514)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:472)
at org.apache.flink.util.InstantiationUtil.deserializeObject(InstantiationUtil.java:539)
at org.apache.flink.util.InstantiationUtil.deserializeObject(InstantiationUtil.java:527)
at org.apache.flink.util.SerializedValue.deserializeValue(SerializedValue.java:67)
at org.apache.flink.runtime.scheduler.DefaultSchedulerFactory.createInstance(DefaultSchedulerFactory.java:101)
at org.apache.flink.runtime.jobmaster.DefaultSlotPoolServiceSchedulerFactory.createScheduler(DefaultSlotPoolServiceSchedulerFactory.java:122)
at org.apache.flink.runtime.jobmaster.JobMaster.createScheduler(JobMaster.java:379)
at org.apache.flink.runtime.jobmaster.JobMaster.<init>(JobMaster.java:356)
at org.apache.flink.runtime.jobmaster.factories.DefaultJobMasterServiceFactory.internalCreateJobMasterService(DefaultJobMasterServiceFactory.java:128)
at org.apache.flink.runtime.jobmaster.factories.DefaultJobMasterServiceFactory.lambda$createJobMasterService$0(DefaultJobMasterServiceFactory.java:100)
at org.apache.flink.util.function.FunctionUtils.lambda$uncheckedSupplier$4(FunctionUtils.java:112)
... 4 more
2024-02-28 16:38:09.695 INFO 59419 --- [ter-io-thread-3] o.a.f.r.dispatcher.StandaloneDispatcher : Job bbc2959a1228d4782ade6888026503f1 has been registered for cleanup in the JobResultStore after reaching a terminal state.
2024-02-28 16:38:09.796 INFO 59419 --- [onPool-worker-2] o.a.f.runtime.minicluster.MiniCluster : Shutting down Flink Mini Cluster
2024-02-28 16:38:09.801 INFO 59419 --- [lt-dispatcher-6] o.a.f.runtime.taskexecutor.TaskExecutor : Stopping TaskExecutor pekko://flink/user/rpc/taskmanager_0.
2024-02-28 16:38:09.802 INFO 59419 --- [lt-dispatcher-6] o.a.f.runtime.taskexecutor.TaskExecutor : Close ResourceManager connection 7f55f62128eada4a14d21fb554184f7a.
2024-02-28 16:38:09.803 INFO 59419 --- [lt-dispatcher-7] o.a.f.r.r.StandaloneResourceManager : Closing TaskExecutor connection 9acc0233-57a4-4d8b-8c97-0e17008e0dca because: The TaskExecutor is shutting down.
2024-02-28 16:38:09.803 INFO 59419 --- [lt-dispatcher-7] o.a.f.r.r.s.FineGrainedSlotManager : Unregistering task executor 2e75d4e948fb7413bdd8ddaa65535673 from the slot manager.
2024-02-28 16:38:09.804 INFO 59419 --- [lt-dispatcher-6] askExecutorStateChangelogStoragesManager : Shutting down TaskExecutorStateChangelogStoragesManager.
2024-02-28 16:38:09.804 INFO 59419 --- [lt-dispatcher-6] ecutorChannelStateExecutorFactoryManager : Shutting down TaskExecutorChannelStateExecutorFactoryManager.
2024-02-28 16:38:09.807 INFO 59419 --- [onPool-worker-2] o.a.f.r.d.DispatcherRestEndpoint : Shutting down rest endpoint.
2024-02-28 16:38:09.813 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.t.DefaultJobLeaderService : Stop job leader service.
2024-02-28 16:38:09.814 INFO 59419 --- [lt-dispatcher-6] .r.s.TaskExecutorLocalStateStoresManager : Shutting down TaskExecutorLocalStateStoresManager.
2024-02-28 16:38:09.818 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.io.disk.FileChannelManagerImpl : FileChannelManager removed spill file directory /home/evuser3/tmp/flink-io-c0cdff82-d2b4-4706-80db-dd401f5c90e3
2024-02-28 16:38:09.819 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.i.n.NettyShuffleEnvironment : Shutting down the network environment and its components.
2024-02-28 16:38:09.823 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.io.disk.FileChannelManagerImpl : FileChannelManager removed spill file directory /home/evuser3/tmp/flink-netty-shuffle-729f4439-d93a-4e70-bbf7-742fdd082feb
2024-02-28 16:38:09.823 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.taskexecutor.KvStateService : Shutting down the kvState service and its components.
2024-02-28 16:38:09.823 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.t.DefaultJobLeaderService : Stop job leader service.
2024-02-28 16:38:09.824 INFO 59419 --- [lt-dispatcher-6] o.a.flink.runtime.filecache.FileCache : removed file cache directory /home/evuser3/tmp/flink-dist-cache-101fc1d5-3b33-4859-b815-78e0f97146c7
2024-02-28 16:38:09.826 INFO 59419 --- [lt-dispatcher-6] o.a.f.runtime.taskexecutor.TaskExecutor : Stopped TaskExecutor pekko://flink/user/rpc/taskmanager_0.
2024-02-28 16:38:09.828 INFO 59419 --- [onPool-worker-7] o.a.f.r.d.DispatcherRestEndpoint : Removing cache directory /home/evuser3/tmp/flink-web-ui
2024-02-28 16:38:09.829 INFO 59419 --- [onPool-worker-7] o.a.f.r.d.DispatcherRestEndpoint : http://localhost:34096 lost leadership
2024-02-28 16:38:09.830 INFO 59419 --- [onPool-worker-7] o.a.f.r.d.DispatcherRestEndpoint : Shut down complete.
2024-02-28 16:38:09.831 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.r.StandaloneResourceManager : Shut down cluster because application is in CANCELED, diagnostics DispatcherResourceManagerComponent has been closed..
2024-02-28 16:38:09.832 INFO 59419 --- [lt-dispatcher-7] r.e.c.DispatcherResourceManagerComponent : Closing components.
2024-02-28 16:38:09.833 INFO 59419 --- [lt-dispatcher-7] a.f.r.d.r.SessionDispatcherLeaderProcess : Stopping SessionDispatcherLeaderProcess.
org.apache.flink.util.FlinkException: Failed to execute job 'evp job'.
2024-02-28 16:38:09.833 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.dispatcher.StandaloneDispatcher : Stopping dispatcher pekko://flink/user/rpc/dispatcher_2.
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.executeAsync(StreamExecutionEnvironment.java:2253)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:2125)
at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.execute(LocalStreamEnvironment.java:68)
2024-02-28 16:38:09.834 INFO 59419 --- [lt-dispatcher-6] o.a.f.r.dispatcher.StandaloneDispatcher : Stopping all currently running jobs of dispatcher pekko://flink/user/rpc/dispatcher_2.
2024-02-28 16:38:09.834 INFO 59419 --- [lt-dispatcher-7] o.a.f.r.r.ResourceManagerServiceImpl : Stopping resource manager service.
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:2099)
at com.modi.evp.biz.job.EvpJob.mainJob(EvpJob.java:40)
我发现使用最新版本的flink-CDC3.1.1,3.2.0版本就也这个问题,我把CDC换成2.4,flink版本退回到1.15,打包这个问题就不存在了,希望对各位有帮助。 如果有新版本的解决方法,也希望有人在这边留言。
使用jar包启动Flink CDC作业时遇到异常,以下是一些可能的原因及对应的解决方法:
my.cnf
,确保已经开启了binlog,并且设置了正确的server-id
。这是Flink CDC正常运作的前提。对于MySQL 5.6版本,虽然官方建议使用5.7以上版本,但在5.6上运行1.4版本的Flink CDC通常没有问题。不过,如果是生产环境,请仔细测试。综上所述,使用jar包启动Flink CDC作业时遇到异常可能是由依赖冲突、数据库配置以及反压等因素导致的。为了解决这个问题,您可以检查并解决依赖冲突、确认数据库配置是否正确、优化作业以减少反压、包含正确版本的JDBC驱动、确保环境一致性以及正确配置类加载器。
这个问题可能是由于在打包时,某些依赖没有被正确地包含在jar包中。你可以尝试以下方法来解决这个问题:
确保你的项目中包含了所有必要的依赖。你可以在pom.xml
文件中检查这些依赖,确保它们都被正确地声明和引用。
使用Maven的maven-assembly-plugin
插件来创建一个包含所有依赖的可执行jar文件。在你的pom.xml
文件中添加以下配置:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>你的主类全名,例如:com.example.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
mvn clean package
java -jar target/your-project-name-version-jar-with-dependencies.jar
这样应该可以解决你的问题。如果问题仍然存在,请检查日志以获取更多详细信息,并确保你的环境配置正确。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
实时计算Flink版是阿里云提供的全托管Serverless Flink云服务,基于 Apache Flink 构建的企业级、高性能实时大数据处理系统。提供全托管版 Flink 集群和引擎,提高作业开发运维效率。