[
https://issues.apache.org/jira/browse/FLINK-13565?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17321482#comment-17321482
]
Flink Jira Bot commented on FLINK-13565:
----------------------------------------
This issue and all of its Sub-Tasks have not been updated for 180 days. So, it
has been labeled "stale-minor". If you are still affected by this bug or are
still interested in this issue, please give an update and remove the label. In
7 days the issue will be closed automatically.
> Integrate springboot found error
> --------------------------------
>
> Key: FLINK-13565
> URL: https://issues.apache.org/jira/browse/FLINK-13565
> Project: Flink
> Issue Type: Improvement
> Components: Table SQL / Client
> Affects Versions: 1.8.1, 1.9.0
> Reporter: feixue
> Priority: Minor
> Labels: stale-minor
>
> when Integrate springboot for 2.1.*, we init flink stream work for spring. in
> our local environment is work find. but when we submit it in dashboard for
> submit new job,and then click show plan, it show a internal error, the detail
> just like this:
> {code:java}
> 2019-08-04 18:05:28 [ERROR] [ispatcherRestEndpoint-thread-3]
> [o.a.f.r.w.h.JarPlanHandler][196] Unhandled exception.
> org.apache.flink.client.program.ProgramInvocationException: The main method
> caused an error: null
> at
> org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:546)
> at
> org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:421)
> at
> org.apache.flink.client.program.OptimizerPlanEnvironment.getOptimizedPlan(OptimizerPlanEnvironment.java:83)
> at
> org.apache.flink.client.program.PackagedProgramUtils.createJobGraph(PackagedProgramUtils.java:80)
> at
> org.apache.flink.runtime.webmonitor.handlers.utils.JarHandlerUtils$JarHandlerContext.toJobGraph(JarHandlerUtils.java:126)
> at
> org.apache.flink.runtime.webmonitor.handlers.JarPlanHandler.lambda$handleRequest$1(JarPlanHandler.java:100)
> at
> java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: java.lang.reflect.InvocationTargetException: null
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47)
> at org.springframework.boot.loader.Launcher.launch(Launcher.java:86)
> at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
> at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:529)
> ... 9 common frames omitted
> Caused by:
> org.apache.flink.client.program.OptimizerPlanEnvironment$ProgramAbortException:
> null
> at
> org.apache.flink.streaming.api.environment.StreamPlanEnvironment.execute(StreamPlanEnvironment.java:70)
> at
> org.apache.flink.streaming.api.environment.StreamPlanEnvironment.execute(StreamPlanEnvironment.java:53)
> at com.ggj.center.boot.demo.DemoApplication.run(DemoApplication.java:73)
> at
> org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:779)
> at
> org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:763)
> at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:318)
> at com.ggj.boot.demo.DemoApplication.main(DemoApplication.java:29)
> ... 22 common frames omitted
> {code}
> just read zhe source code, we found in PackageProgram.java file, the
> callMainMethod() call main method and catch InvocationTargetException for it.
> when throw ProgramAbortException, it will throw as InvocationTargetException
> and it target is ProgramAbortException. so flink can catch this and check the
> target exception for Error and throw angin.
>
> {code:java}
> try {
> mainMethod.invoke(null, (Object) args);
> }
> catch (IllegalArgumentException e) {
> throw new ProgramInvocationException("Could not invoke the main method,
> arguments are not matching.", e);
> }
> catch (IllegalAccessException e) {
> throw new ProgramInvocationException("Access to the main method was
> denied: " + e.getMessage(), e);
> }
> catch (InvocationTargetException e) {
> Throwable exceptionInMethod = e.getTargetException();
> if (exceptionInMethod instanceof Error) {
> throw (Error) exceptionInMethod;
> } else if (exceptionInMethod instanceof ProgramParametrizationException) {
> throw (ProgramParametrizationException) exceptionInMethod;
> } else if (exceptionInMethod instanceof ProgramInvocationException) {
> throw (ProgramInvocationException) exceptionInMethod;
> } else {
> throw new ProgramInvocationException("The main method caused an error:
> " + exceptionInMethod.getMessage(), exceptionInMethod);
> }
> }
> {code}
>
> OptimizerPlanEnvironment will catch it and check optimizerPlan is not null
> and decision it run success or throw ProgramInvocationException.
>
> {code:java}
> try {
> prog.invokeInteractiveModeForExecution();
> }
> catch (ProgramInvocationException e) {
> throw e;
> }
> catch (Throwable t) {
> // the invocation gets aborted with the preview plan
> if (optimizerPlan != null) {
> return optimizerPlan;
> } else {
> throw new ProgramInvocationException("The program caused an error: ",
> t);
> }
> }{code}
>
> In springboot to start application is reflect main method also, when we
> operation in dashboard, zhe cell order is: flink > springboot > flink stream
> client. Two reflect make the
> InvocationTargetException target exception is InvocationTargetException not
> Error.
> For this, we can't Integrate springboot, or there have any other method to do
> this, please tell me, thank you.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)