有人知道在远程Flink集群上运行程序时以下错误的根源是什么吗?
我该如何解决?
org.apache.flink.client.program.ProgramInvocationException: The main method caused an error.
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:512)
at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:395)
at org.apache.flink.client.program.Client.runBlocking(Client.java:252)
at org.apache.flink.client.CliFrontend.executeProgramBlocking(CliFrontend.java:675)
at org.apache.flink.client.CliFrontend.run(CliFrontend.java:326)
at org.apache.flink.client.CliFrontend.parseParameters(CliFrontend.java:977)
at org.apache.flink.client.CliFrontend.main(CliFrontend.java:1027)
Caused by: org.apache.flink.api.common.InvalidProgramException: The RemoteEnvironment cannot be instantiated when running in a pre-defined context (such as Command Line Client, Scala Shell, or TestEnvironment)
at org.apache.flink.api.java.RemoteEnvironment.<init>(RemoteEnvironment.java:118)
at org.apache.flink.api.java.RemoteEnvironment.<init>(RemoteEnvironment.java:78)
at org.apache.flink.api.java.ExecutionEnvironment.createRemoteEnvironment(ExecutionEnvironment.java:1155)
at org.apache.flink.test.myProj.main(myProj.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:497)
... 6 more
在Flink程序中,您需要使用
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
以检索CCD_ 1。这会自动获取本地环境(从IDE执行时)或集群环境(使用命令行客户端时)。
如果您想向远程集群提交Flink程序,则只能使用RemoteEnvironment
。
要将作业提交到远程环境(其中代码使用.createRemoteEnvironment),您只能通过API调用而不是从CLI 进行此操作