This article outlines an issue with SCDF task creation failing with the below error
org.springframework.context.ApplicationContextException: Failed to start bean 'taskLifecycleListener'
Caused by: java.lang.IllegalArgumentException: Invalid TaskExecution, ID <ID-number> not found
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-09-25T11:19:05.262Z ERROR 1 --- [Check Debit Schedule Task] [ main] o.s.boot.SpringApplication : Application run failed
The core of the problem is a mismatch between the SCDF server's knowledge of the task database and the task application's configuration for that same database.
The application context fails to start because the taskLifecycleListener bean fails to initialize.
You can define CustomTaskConfigurer in your code as below:
@Component
public class CustomTaskConfigurer extends DefaultTaskConfigurer {
@Autowired
public CustomTaskConfigurer(
@Qualifier("springCloudDataSource") DataSource dataSource, // ← KEY FIX #1
TaskProperties taskProperties, // ← KEY FIX #2
ApplicationContext context
) {
super(dataSource, taskProperties.getTablePrefix(), context);
}
}
@Qualifier("springCloudDataSource") explicitly tells Spring Cloud Task to use the same datasource that SCDF uses for task metadata tables (TASK_EXECUTION, TASK_EXECUTION_PARAMS, etc.)
taskProperties.getTablePrefix() ensures the correct prefix (default: TASK_) is used. If SCDF and your app used different prefixes, lookups would fail.