After upgrading our Spring Boot project from 3.1.6 to 3.2 we can't start the application, as there is a bean composition error occurring which is cause by two external dependencies that we are using.

Dependencies: - io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter:1.32.0-alpha - org.springdoc:springdoc-openapi-starter-webflux-ui:2.3.0

When we start the application, we get the following error: Parameter 1 of method otelInstrumentationWithSpanAspect in io.opentelemetry.instrumentation.spring.autoconfigure.instrumentation.annotations.InstrumentationAnnotationsAutoConfiguration required a single bean, but 2 were found: - parameterNameDiscoverer: defined by method 'parameterNameDiscoverer' in class path resource [io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/annotations/InstrumentationAnnotationsAutoConfiguration.class] - localSpringDocParameterNameDiscoverer: defined by method 'localSpringDocParameterNameDiscoverer' in class path resource [org/springdoc/core/configuration/SpringDocConfiguration.class]

The conflicting beans are implemented here: - https://github.com/springdoc/springdoc-openapi/blob/a714f41b7761a2edb8ed4f7874de1d8f6ef8bb10/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java#L187C1-L187C76 - https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/27ee816a26c340d2d5fe94904435e6b19d84cda3/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/annotations/InstrumentationAnnotationsAutoConfiguration.java#L29

As we thought, it might be related, we tried out the java-parameters flag (as we are having a Kotlin application) from here: https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retention But it didn't change the outcome.

I've created a minimal repro application, only containing Spring Boot 3.2, spring-boot-starter-webflux and the before mentioned dependencies. When the application is started, we run in the above error. If one dependency is commented out or if Spring Boot is rolled back to version 3.1.6, the error disappears. demo.zip

Comment From: wilkinsona

Thanks for the sample.

This is due to code not being compiled -parameters, but it's Otel's code not yours. It works with Spring Framework 6.0 due to a rather brittle arrangement – there is a bean named parameterNameDiscoverer and there is a method parameter with the same name. This matching is relying on debug information in the class files. You can see warnings related to this in the logs when running the app with Spring Framework 6.0:

2023-12-08T10:34:55.113Z  WARN 8756 --- [           main] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: io.opentelemetry.instrumentation.spring.autoconfigure.aspects.TraceAspectAutoConfiguration

Support for this was deprecated in Spring Framework 6.0 and removed in Spring Framework 6.1. Its removal means that the matching is no longer possible and one of the two beans can no longer be selected. You will also see the same failure if you use Spring Framework 6.1.x with Spring Boot 3.1.x. The fix will require compiling the Otel code with -parameters or the addition of @Qualifier to the injection point so that the bean named parameterNameDiscoverer is injected.