Skip to content

Task scheduler configured by XML is not eligible for getting processed by all BeanPostProcessors #34015

Closed
@ProgMiner

Description

@ProgMiner

Hello!

Seems like XML-based scheduling configuration from documentation produces well-known "is not eligible" warning.

Minimal sample

Tested on Spring Core versions: 6.1.15, 6.2.0.

applicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
    <task:scheduler id="scheduler" pool-size="5" />
    <task:annotation-driven scheduler="scheduler" />
</beans>

Reference: https://docs.spring.io/spring-framework/reference/integration/scheduling.html#scheduling-enable-annotation-support

Main.java:

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

    public static void main(String[] args) {
        new ClassPathXmlApplicationContext("applicationContext.xml");
    }
}

Starting results in singular log message:

WARNING: Bean 'scheduler' of type [org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [org.springframework.context.annotation.internalScheduledAnnotationProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE.

Unfortunately, I haven't found any way to mark this bean as infrastructure using only XML.

Related: #32055, spring-projects/spring-integration#7602

Best regards!

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions