{"record":{"id":"52f054d5253d0676","repo":"apache/flink","slug":"could-not-execute-application","errorCode":null,"errorMessage":"Could not execute application.","messagePattern":"Could not execute application\\.","errorType":"exception","errorClass":"FlinkRuntimeException","httpStatus":null,"severity":"critical","filePath":"flink-clients/src/main/java/org/apache/flink/client/deployment/application/DetachedApplicationRunner.java","lineNumber":88,"sourceCode":"        return tryExecuteJobs(dispatcherGateway, program, configuration);\n    }\n\n    private List<JobID> tryExecuteJobs(\n            final DispatcherGateway dispatcherGateway,\n            final PackagedProgram program,\n            final Configuration configuration) {\n        configuration.set(DeploymentOptions.ATTACHED, false);\n\n        final List<JobID> applicationJobIds = new ArrayList<>();\n        final PipelineExecutorServiceLoader executorServiceLoader =\n                new WebSubmissionExecutorServiceLoader(applicationJobIds, dispatcherGateway);\n\n        try {\n            ClientUtils.executeProgram(\n                    executorServiceLoader, configuration, program, enforceSingleJobExecution, true);\n        } catch (ProgramInvocationException e) {\n            LOG.warn(\"Could not execute application: \", e);\n            throw new FlinkRuntimeException(\"Could not execute application.\", e);\n        }\n\n        return applicationJobIds;\n    }\n}\n","sourceCodeStart":70,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/deployment/application/DetachedApplicationRunner.java#L70-L94","documentation":"Thrown by DetachedApplicationRunner.run when ClientUtils.executeProgram throws a ProgramInvocationException. In detached application mode, Flink executes the user's main() method directly on the submitting client before the dispatcher takes over. If the program fails to start (missing main method, class loading failure, main() throws), the exception is logged at WARN level and re-thrown as FlinkRuntimeException. This is distinct from job runtime failures — it means the program couldn't even be invoked.","triggerScenarios":"The JAR's main class is not found or doesn't have a public static void main(String[]); the main method throws an exception during startup; the program's pipeline construction fails before submission; classpath issues prevent the program from loading.","commonSituations":"Wrong main class specified; JAR built with incompatible dependencies; the program fails during environment configuration (e.g., cannot connect to a source during stream graph construction); missing configuration properties needed at startup.","solutions":["Check the wrapped ProgramInvocationException cause for the specific startup failure","Verify the main class name and that it has a valid main method","Test the JAR locally first with `java -cp` to isolate classpath issues","Ensure all required configuration properties are set before the program's main() runs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    runner.run(program, configuration);\n} catch (FlinkRuntimeException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof ProgramInvocationException) {\n        Throwable root = cause.getCause();\n        LOG.error(\"Application failed to start: {}\", root.getMessage(), root);\n    }\n    throw e;\n}","preventionTips":["Test the JAR locally with java -cp before submitting in detached application mode","Verify the main class exists and has a valid main(String[]) method","Ensure all required dependencies are bundled in the fat JAR","Validate configuration properties needed at program startup"],"tags":["application-mode","program-execution","detached","class-loading"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}