记录一次jar包发布到FlinkUI遇到的问题

记录一次jar包发布到FlinkUI遇到的问题

2022-04-25 15:23:26,457 WARN  org.apache.flink.runtime.webmonitor.handlers.JarRunHandler   [] - Configuring the job submission via query parameters is deprecated. Please migrate to submitting a JSON request instead.
2022-04-25 15:23:26,471 INFO  org.apache.flink.client.ClientUtils                          [] - Starting program (detached: true)
2022-04-25 15:23:26,472 WARN  org.apache.flink.client.deployment.application.DetachedApplicationRunner [] - Could not execute application: 
org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: The LocalStreamEnvironment cannot be used when submitting a program through a client, or running in a TestEnvironment context.
	at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:372) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:222) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:114) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at org.apache.flink.client.deployment.application.DetachedApplicationRunner.tryExecuteJobs(DetachedApplicationRunner.java:84) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at org.apache.flink.client.deployment.application.DetachedApplicationRunner.run(DetachedApplicationRunner.java:70) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at org.apache.flink.runtime.webmonitor.handlers.JarRunHandler.lambda$handleRequest$0(JarRunHandler.java:104) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: org.apache.flink.api.common.InvalidProgramException: The LocalStreamEnvironment cannot be used when submitting a program through a client, or running in a TestEnvironment context.
	at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.validateAndGetConfiguration(LocalStreamEnvironment.java:57) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.<init>(LocalStreamEnvironment.java:52) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.createLocalEnvironment(StreamExecutionEnvironment.java:2264) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(StreamExecutionEnvironment.java:2288) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	at com.flink.test.SocketWordCount.main(SocketWordCount.java:23) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:355) ~[flink-dist_2.12-1.14.4.jar:1.14.4]
	... 7 more
2022-04-25 15:23:26,473 ERROR org.apache.flink.runtime.webmonitor.handlers.JarRunHandler   [] - Exception occurred in REST handler: Could not execute application.

在Flink UI上传jar包时,如果用 createLocalEnvironmentWithWebUI 的方式则不能使用 flink run 的方式提交,只能使用Java -jar的方式

若要使用集群提交,需通过StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment() ,创建流式对象

        StreamExecutionEnvironment env =  StreamExecutionEnvironment.getExecutionEnvironment();
//      createLocalEnvironmentWithWebUI(new org.apache.flink.configuration.Configuration());

image

服务器开启端口,nc -lk 8082

image

posted @ 2022-04-25 15:59  Leejk  阅读(2289)  评论(1编辑  收藏  举报