In the batch sample from spring-native in sb-3.0.x branch, running the native image fails with the following exception:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchApplication': Unsatisfied dependency expressed through field 'jobBuilderFactory': Error creating bean with name 'org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration': Unsatisfied dependency expressed through field 'configurers': Error creating bean with name 'batchConfigurer': Unable to initialize Spring Batch
    at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:195) ~[na:na]
    at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveAndSet(AutowiredFieldValueResolver.java:167) ~[na:na]
    at com.example.batch.BatchApplication__Autowiring.apply(BatchApplication__Autowiring.java:14) ~[na:na]
    at org.springframework.beans.factory.support.InstanceSupplier.lambda$andThen$0(InstanceSupplier.java:64) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1223) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1209) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1156) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:566) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:526) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:930) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:926) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:592) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:735) ~[batch:3.0.0-SNAPSHOT]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:431) ~[batch:3.0.0-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[batch:3.0.0-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1307) ~[batch:3.0.0-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1296) ~[batch:3.0.0-SNAPSHOT]
    at com.example.batch.BatchApplication.main(BatchApplication.java:49) ~[batch:0.0.1-SNAPSHOT]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration': Unsatisfied dependency expressed through field 'configurers': Error creating bean with name 'batchConfigurer': Unable to initialize Spring Batch
    at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:195) ~[na:na]
    at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveAndSet(AutowiredFieldValueResolver.java:167) ~[na:na]
    at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration__Autowiring.apply(SimpleBatchConfiguration__Autowiring.java:17) ~[na:na]
    at org.springframework.beans.factory.support.InstanceSupplier.lambda$andThen$0(InstanceSupplier.java:64) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1223) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1209) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1156) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:566) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:526) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:225) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1267) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1228) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:483) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:338) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration__BeanDefinitions.getJobBuildersInstance(AbstractBatchConfiguration__BeanDefinitions.java:30) ~[na:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1223) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1209) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1156) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:566) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:526) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1374) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1294) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:189) ~[na:na]
    ... 21 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchConfigurer': Unable to initialize Spring Batch
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1752) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:604) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:526) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1590) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1554) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1445) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1332) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1294) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.aot.AutowiredFieldValueResolver.resolveValue(AutowiredFieldValueResolver.java:189) ~[na:na]
    ... 52 common frames omitted
Caused by: java.lang.IllegalStateException: Unable to initialize Spring Batch
    at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.initialize(BasicBatchConfigurer.java:107) ~[batch:0.0.1-SNAPSHOT]
    at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.afterPropertiesSet(BasicBatchConfigurer.java:96) ~[batch:0.0.1-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1798) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1748) ~[batch:6.0.0-SNAPSHOT]
    ... 65 common frames omitted
Caused by: org.springframework.core.Constants$ConstantException: Field 'PROPAGATION_REQUIRED' not found in class [org.springframework.transaction.TransactionDefinition]
    at org.springframework.core.Constants.asObject(Constants.java:145) ~[na:na]
    at org.springframework.core.Constants.asNumber(Constants.java:113) ~[na:na]
    at org.springframework.transaction.support.DefaultTransactionDefinition.setPropagationBehaviorName(DefaultTransactionDefinition.java:122) ~[batch:6.0.0-SNAPSHOT]
    at org.springframework.transaction.interceptor.TransactionAttributeEditor.setAsText(TransactionAttributeEditor.java:65) ~[na:na]
    at org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource.setProperties(NameMatchTransactionAttributeSource.java:87) ~[na:na]
    at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean.initializeProxy(AbstractJobRepositoryFactoryBean.java:182) ~[batch:5.0.0-M3]
    at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean.afterPropertiesSet(AbstractJobRepositoryFactoryBean.java:212) ~[batch:5.0.0-M3]
    at org.springframework.batch.core.repository.support.JobRepositoryFactoryBean.afterPropertiesSet(JobRepositoryFactoryBean.java:225) ~[na:na]
    at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.createJobRepository(BasicBatchConfigurer.java:134) ~[batch:0.0.1-SNAPSHOT]
    at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.initialize(BasicBatchConfigurer.java:102) ~[batch:0.0.1-SNAPSHOT]
    ... 68 common frames omitted

I guess there are some hints missing.

Comment From: christophstrobl

RuntimeHintsUtils.registerAnnotation(hints, org.springframework.transaction.annotation.Transactional.class);

hints.reflection()
    .registerTypes(asList(
        TypeReference.of(org.springframework.transaction.annotation.Isolation.class),
        TypeReference.of(org.springframework.transaction.annotation.Propagation.class),
        TypeReference.of(org.springframework.transaction.TransactionDefinition.class)),
        hint -> ...)

hints.reflection()
    .registerTypes(asList(
        TypeReference.of(AutoProxyRegistrar.class),
        TypeReference.of(ProxyTransactionManagementConfiguration.class),
        TypeReference.of("org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor$1")), ...

(updated to make use of RuntimeHintsUtils.registerAnnotation)

Comment From: sdeleuze

@christophstrobl Thanks for the hints ;-) What about annotating ProxyTransactionManagementConfiguration with @ImportRuntimeHints(TransactionRuntimeHintsRegistrar.class) where TransactionRuntimeHintsRegistrar would register those entries?

Comment From: snicoll

Please don't register proxies like that, and use registerAnnotation.

Comment From: sbrannen

@christophstrobl, do you recall why you needed to register reflection hints for the enum constant fields in Isolation and Propagation?

I'm asking, because while working on #30854 I wondered if we still need those hints.

Comment From: sbrannen

@christophstrobl, do you recall why you needed to register reflection hints for the enum constant fields in Isolation and Propagation?

@sdeleuze, Christoph informed me that he does not recall. Do you recall?

Comment From: sdeleuze

I don't, but if we change something here, worth to check if we have a related smoke test and check after that it does not break. In any case, I would advise to test on a sample with both 22.3 and 23.0 GraalVM releases.