apache/flink · critical · FlinkRuntimeException
Could not execute application.
Error message
Could not execute application.
What it means
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.
Source
Thrown at flink-clients/src/main/java/org/apache/flink/client/deployment/application/DetachedApplicationRunner.java:88
return tryExecuteJobs(dispatcherGateway, program, configuration);
}
private List<JobID> tryExecuteJobs(
final DispatcherGateway dispatcherGateway,
final PackagedProgram program,
final Configuration configuration) {
configuration.set(DeploymentOptions.ATTACHED, false);
final List<JobID> applicationJobIds = new ArrayList<>();
final PipelineExecutorServiceLoader executorServiceLoader =
new WebSubmissionExecutorServiceLoader(applicationJobIds, dispatcherGateway);
try {
ClientUtils.executeProgram(
executorServiceLoader, configuration, program, enforceSingleJobExecution, true);
} catch (ProgramInvocationException e) {
LOG.warn("Could not execute application: ", e);
throw new FlinkRuntimeException("Could not execute application.", e);
}
return applicationJobIds;
}
}
View on GitHub (pinned to 2f3c205e92)
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
Defensive patterns
Strategy: try-catch
Try / catch
try {
runner.run(program, configuration);
} catch (FlinkRuntimeException e) {
Throwable cause = e.getCause();
if (cause instanceof ProgramInvocationException) {
Throwable root = cause.getCause();
LOG.error("Application failed to start: {}", root.getMessage(), root);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Application Mode not supported by standalone deployments.
- Could not create the Dispatcher rpc endpoint.
- Invalid cluster id "%s". The expected format is [0-9a-fA-F]{
- Cannot deserialize and unwrap accumulators properly.
- The program's entry point class '{className}' was not found
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/52f054d5253d0676.
Report an issue: GitHub.