spring-cloud-gcp: Exception on application start with Spring Boot 3.2 and com.google.cloud:spring-cloud-gcp-starter-pubsub:4.8.4`

Describe the bug My application fails to start with an exception: Error creating bean with name 'com.google.cloud.spring.autoconfigure.pubsub.health.PubSubHealthIndicatorAutoConfiguration': Failed to instantiate [com.google.cloud.spring.autoconfigure.pubsub.health.PubSubHealthIndicatorAutoConfiguration]: Constructor threw exception

I am upgrading my application to spring boot 3.2, with Java 21, and com.google.cloud:spring-cloud-gcp-starter-pubsub:4.8.4

I do not have any other GCP Projects in my application.

I am temporarily able to start myt application by using the following property. management.health.pubsub.enabled = false

Callstack:

Error creating bean with name 'com.google.cloud.spring.autoconfigure.pubsub.health.PubSubHealthIndicatorAutoConfiguration': Failed to instantiate [com.google.cloud.spring.autoconfigure.pubsub.health.PubSubHealthIndicatorAutoConfiguration]: Constructor threw exception
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.google.cloud.spring.autoconfigure.pubsub.health.PubSubHealthIndicatorAutoConfiguration': Failed to instantiate [com.google.cloud.spring.autoconfigure.pubsub.health.PubSubHealthIndicatorAutoConfiguration]: Constructor threw exception
	at app//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:322)
	at app//org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:310)
	at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1356)
	at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1193)
	at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563)
	at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
	at app//org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325)
	at app//org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at app//org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323)
	at app//org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973)
	at app//org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:946)
	at app//org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:616)
	at app//org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
	at app//org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753)
	at app//org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:455)
	at app//org.springframework.boot.SpringApplication.run(SpringApplication.java:323)
	at app//org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137)
	at app//org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
	at app//org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
	at app//org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1442)
	at app//org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:552)
	at app//org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137)
	at app//org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108)
	at app//org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:225)
	at app//org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:152)
	at app//org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:130)
	at app//org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:141)
	at app//org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:97)
	at app//org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:247)
	at app//org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:163)
	at java.base@21.0.1/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base@21.0.1/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base@21.0.1/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
	at java.base@21.0.1/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base@21.0.1/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base@21.0.1/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
	at java.base@21.0.1/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
	at java.base@21.0.1/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
	at java.base@21.0.1/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
	at java.base@21.0.1/java.util.Optional.orElseGet(Optional.java:364)
	at java.base@21.0.1/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base@21.0.1/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.google.cloud.spring.autoconfigure.pubsub.health.PubSubHealthIndicatorAutoConfiguration]: Constructor threw exception
	at app//org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:223)
	at app//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:111)
	at app//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:319)
	... 42 more
Caused by: java.lang.NoSuchMethodError: org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfiguration: method 'void <init>()' not found
	at com.google.cloud.spring.autoconfigure.pubsub.health.PubSubHealthIndicatorAutoConfiguration.<init>(PubSubHealthIndicatorAutoConfiguration.java:55)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:210)

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 9
  • Comments: 26 (9 by maintainers)

Most upvoted comments

This has been merged into main. The next release of Spring Cloud GCP is expected this week and will contain these updates.

@burkedavison Spring Cloud 2023.0.0 is released

ah yes i got it to work now. there were some spring cloud gcp dependencies we were pulling in transitively that were still on 4.8.4. thanks

I’m also experiencing this issue and it is blocking upgrade to Spring Boot 3.2 which is desirable due to virtual threads. Appreciate if you would prioritize fixing this ASAP.

I’d expect Spring Cloud GCP to be ahead of these issues and test Spring Boot release candidates before they are released so that any incompatibility issues are resolved in advance. It’d be great if you can make that part of the process.