Skip to content

native-image: Problem with Scheduled annotation #28696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mhalbritter opened this issue Jun 24, 2022 · 3 comments
Closed

native-image: Problem with Scheduled annotation #28696

mhalbritter opened this issue Jun 24, 2022 · 3 comments
Assignees
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@mhalbritter
Copy link
Contributor

When running the native-image from the spring-native sample scheduling-tasks on the sb-3.0.x branch, i get the following exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schedulingTasksApplication': Invalid declaration of container type [org.springframework.scheduling.annotation.Schedules] for repeatable annotation [org.springframework.scheduling.annotation.Scheduled]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:611) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:526) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:930) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:926) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:592) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:735) ~[scheduling-tasks:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:431) ~[scheduling-tasks:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[scheduling-tasks:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1307) ~[scheduling-tasks:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1296) ~[scheduling-tasks:3.0.0-SNAPSHOT]
	at com.example.schedulingtasks.SchedulingTasksApplication.main(SchedulingTasksApplication.java:13) ~[scheduling-tasks:0.0.1-SNAPSHOT]
Caused by: org.springframework.core.annotation.AnnotationConfigurationException: Invalid declaration of container type [org.springframework.scheduling.annotation.Schedules] for repeatable annotation [org.springframework.scheduling.annotation.Scheduled]
	at org.springframework.core.annotation.RepeatableContainers$ExplicitRepeatableContainer.<init>(RepeatableContainers.java:219) ~[na:na]
	at org.springframework.core.annotation.RepeatableContainers.of(RepeatableContainers.java:117) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.core.annotation.AnnotatedElementUtils.getRepeatableAnnotations(AnnotatedElementUtils.java:759) ~[na:na]
	at org.springframework.core.annotation.AnnotatedElementUtils.getMergedRepeatableAnnotations(AnnotatedElementUtils.java:455) ~[na:na]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.lambda$postProcessAfterInitialization$0(ScheduledAnnotationBeanPostProcessor.java:366) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.core.MethodIntrospector.lambda$selectMethods$0(MethodIntrospector.java:74) ~[na:na]
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:366) ~[na:na]
	at org.springframework.core.MethodIntrospector.selectMethods(MethodIntrospector.java:72) ~[na:na]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.postProcessAfterInitialization(ScheduledAnnotationBeanPostProcessor.java:364) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1755) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:604) ~[scheduling-tasks:6.0.0-SNAPSHOT]
	... 14 common frames omitted
Caused by: java.lang.NoSuchMethodException: No value method found
	at org.springframework.core.annotation.RepeatableContainers$ExplicitRepeatableContainer.<init>(RepeatableContainers.java:203) ~[na:na]
	... 25 common frames omitted
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 24, 2022
@sdeleuze sdeleuze self-assigned this Jun 28, 2022
@sdeleuze sdeleuze added type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 28, 2022
@sdeleuze sdeleuze added this to the 6.0.0-M5 milestone Jun 28, 2022
@snicoll
Copy link
Member

snicoll commented Jul 4, 2022

@sdeleuze is the registrar really necessary? Unless the implementation has changed, adding @Reflective should register the annotation as well.

Now the agent is available it would be nice to have a test for this.

@sdeleuze
Copy link
Contributor

sdeleuze commented Jul 4, 2022

I will double check.

@sdeleuze
Copy link
Contributor

sdeleuze commented Jul 4, 2022

It does not work without the registrar (maybe something to refine on @Reflective to refine later), I will add related tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants