Hi,
given a new project generated on the Initializr with this url using spring boot 3.0.0.m5 with R2DBC + Webflux + Actuator, i get an error on startup running the native-image that results from compiling it.
... 60 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'r2dbcHealthContributor': Instantiation of supplied bean failed
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1236) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1210) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1157) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1591) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1555) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1474) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1333) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1295) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:332) ~[na:na]
... 75 common frames omitted
Caused by: java.lang.IllegalStateException: Unable to create health indicator class org.springframework.boot.actuate.r2dbc.ConnectionFactoryHealthIndicator for bean type interface io.r2dbc.spi.ConnectionFactory
at org.springframework.boot.actuate.autoconfigure.health.AbstractCompositeHealthContributorConfiguration.createIndicator(AbstractCompositeHealthContributorConfiguration.java:68) ~[reactive:3.0.0-M5]
at org.springframework.boot.actuate.autoconfigure.health.AbstractCompositeHealthContributorConfiguration.createContributor(AbstractCompositeHealthContributorConfiguration.java:54) ~[reactive:3.0.0-M5]
at org.springframework.boot.actuate.autoconfigure.r2dbc.ConnectionFactoryHealthContributorAutoConfiguration.r2dbcHealthContributor(ConnectionFactoryHealthContributorAutoConfiguration.java:58) ~[reactive:3.0.0-M5]
at org.springframework.boot.actuate.autoconfigure.r2dbc.ConnectionFactoryHealthContributorAutoConfiguration__BeanDefinitions.lambda$getRdbcHealthContributorInstanceSupplier$1(ConnectionFactoryHealthContributorAutoConfiguration__BeanDefinitions.java:40) ~[na:na]
at org.springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:63) ~[reactive:6.0.0-M6]
at org.springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:51) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$withGenerator$0(BeanInstanceSupplier.java:175) ~[na:na]
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68) ~[reactive:6.0.0-M6]
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54) ~[reactive:6.0.0-M6]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:210) ~[na:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1225) ~[reactive:6.0.0-M6]
... 90 common frames omitted
Caused by: java.lang.NoSuchMethodException: org.springframework.boot.actuate.r2dbc.ConnectionFactoryHealthIndicator.<init>(io.r2dbc.spi.ConnectionFactory)
at java.lang.Class.getConstructor0(DynamicHub.java:3585) ~[reactive:na]
at java.lang.Class.getDeclaredConstructor(DynamicHub.java:2754) ~[reactive:na]
at org.springframework.boot.actuate.autoconfigure.health.AbstractCompositeHealthContributorConfiguration.createIndicator(AbstractCompositeHealthContributorConfiguration.java:64) ~[reactive:3.0.0-M5]
if i register a reflection hint for ConnectionFactoryHealthIndicator specifying MemberCategory.values(), then it works.
from the looks of it the CompositeHealthindicator is reflectively instantiating beans
i apologize if you've already seen this issue
Comment From: rishiraj88
Thanks, @wilkinsona