Skip to content
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

BeanDefinitionOverrideException using sleuth-3.1.0-RC1 #64

Closed
oburgosm opened this issue Nov 30, 2021 · 3 comments · Fixed by #68
Closed

BeanDefinitionOverrideException using sleuth-3.1.0-RC1 #64

oburgosm opened this issue Nov 30, 2021 · 3 comments · Fixed by #68
Assignees

Comments

@oburgosm
Copy link
Contributor

oburgosm commented Nov 30, 2021

I have a library that need an optional dependency with spring-cloud-sleuth and another dependency with datasource-proxy-spring-boot-starter for some datasources customizations. This work for me until I updated to sleuth 3.1.0-RC1. I get a bean name collision between classes defined in:

  • org.springframework.cloud.sleuth.autoconfig.instrument.jdbc.DataSourceProxyConfiguration
  • com.github.gavlyukovskiy.boot.jdbc.decorator.dsproxy.DataSourceProxyConfiguration
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'proxyDataSourceBuilderConfigurer' defined in class path resource [org/springframework/cloud/sleuth/autoconfig/instrument/jdbc/DataSourceProxyConfiguration.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.sleuth.autoconfig.instrument.jdbc.DataSourceProxyConfiguration; factoryMethodName=proxyDataSourceBuilderConfigurer; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/sleuth/autoconfig/instrument/jdbc/DataSourceProxyConfiguration.class]] for bean 'proxyDataSourceBuilderConfigurer': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.github.gavlyukovskiy.boot.jdbc.decorator.dsproxy.DataSourceProxyConfiguration; factoryMethodName=proxyDataSourceBuilderConfigurer; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/github/gavlyukovskiy/boot/jdbc/decorator/dsproxy/DataSourceProxyConfiguration.class]] bound.

There is a plan to avoid this name collision to allow that both artifacts can be used in the same application?

@david-kerwick
Copy link

david-kerwick commented Dec 3, 2021

Hi,
It seems a good part of this project has been rolled into Sleuth, hence the collisions.
https://docs.spring.io/spring-cloud-sleuth/docs/3.1.0/reference/html/integrations.html#sleuth-jdbc-integration

I got it to work again by removing this starter, adding p6spy normally and configuring p6spy using the Sleuth properties.
It seems to ignore my spy.properties for some reason

Hope that helps

@gavlyukovskiy
Copy link
Owner

gavlyukovskiy commented Dec 7, 2021

Hi @oburgosm, @david-kerwick, it's correct, most of this project was copied to spring-cloud-sleuth with very few changes. Most notable is that logging will be disabled by default (spring.sleuth.jdbc.datasource-proxy.query.enable-logging=false) since it doesn't make much sense to do that by default in tracing context. All other configurations were migrated to spring.sleuth.jdbc and tracing span names were also changed, but overall everything should work.

There is a plan to avoid this name collision to allow that both artifacts can be used in the same application?

I was planning to add graceful delegation logic, but I couldn't get some time to do that yet.

It seems to ignore my spy.properties for some reason

I can also take a look at that when I have time, do you have any sample code to reproduce that?

@david-kerwick
Copy link

Hi,
Thanks, I was wrong about the spy.properties. I thought setting spring.sleuth.jdbc.datasource-proxy.query.enable-logging=true would enable it and the appenders it contained. But once I set spring.sleuth.jdbc.p6spy.enable-logging=true everything works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants