Version 4.0.1 can not be used in a service with other binders on the classpath
kabennett opened this issue · 4 comments
kabennett commented
I have a project that includes the following two dependencies:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kinesis</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
<version>4.0.4</version>
</dependency>
When the microservice starts up, we encounter the following exception:
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'kafkaExtendedPropertiesDefaultMappingsProvider' defined in class path resource [org/springframework/cloud/stream/binder/kinesis/config/ExtendedBindingHandlerMappingsProviderConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.stream.binder.kinesis.config.ExtendedBindingHandlerMappingsProviderConfiguration; factoryMethodName=kafkaExtendedPropertiesDefaultMappingsProvider; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [org/springframework/cloud/stream/binder/kinesis/config/ExtendedBindingHandlerMappingsProviderConfiguration.class]] for bean 'kafkaExtendedPropertiesDefaultMappingsProvider' since there is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.stream.binder.kafka.config.ExtendedBindingHandlerMappingsProviderConfiguration; factoryMethodName=kafkaExtendedPropertiesDefaultMappingsProvider; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [org/springframework/cloud/stream/binder/kafka/config/ExtendedBindingHandlerMappingsProviderConfiguration.class]] bound.
at org.springframework.beans.factory.support.DefaultListableBeanFactory.registerBeanDefinition(DefaultListableBeanFactory.java:1015)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:277)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:428)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:289)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:775)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:597)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:455)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:323)
at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1442)
at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:552)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:225)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:152)
... 17 more
Version of the framework
-
Spring Boot 3.2.0
-
Spring Cloud 2023.0.0
-
Spring Cloud Stream Binder for Kinesis 4.0.1
Expected behavior
- Bean name conflicts should not be present when more than one binder is on the classpath.
- Multiple binders should be able to be used per this link.
Additional context
- Note that this problem is triggered when we upgrade Spring Cloud Stream Binder for Kinesis from 4.0.0 to 4.0.1. This exact problem also occurs when Spring Cloud is at version 2022.0.4 and Spring Boot is at version 3.0.13.
artembilan commented
Duplication of: #214.
The fix is available in 4.0.2-M2
.
We probably will release 4.0.2
somewhere next week or so.
kabennett commented
When is 4.0.2
going to be released?
artembilan commented
Done: https://github.com/spring-cloud/spring-cloud-stream-binder-aws-kinesis/releases/tag/v4.0.2.
Sorry for delay.
kabennett commented
No problem. Thank you, @artembilan.