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

It is not possible to provide a custom TransactionProvider bean for JOOQ #32899

Closed
lukas-krecan opened this issue Oct 27, 2022 · 4 comments
Closed
Labels
type: bug A general bug
Milestone

Comments

@lukas-krecan
Copy link

lukas-krecan commented Oct 27, 2022

We are using jOOQ and Kafka in one project. When we enabled Kafka transactions by providing spring.kafka.producer.transaction-id-prefix configuration property, transaction managers started to clash in JooqAutoConfiguration with the following exception. I would expect jOOQ auto-configuration to pick the right TX manager.

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'transactionProvider' defined in class path resource [org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.class]: Unsatisfied dependency expressed through method 'transactionProvider' parameter 0; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.transaction.PlatformTransactionManager' available: expected single matching bean but found 2: transactionManager,kafkaTransactionManager
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.getIfAvailable(DefaultListableBeanFactory.java:2032)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.ifAvailable(DefaultListableBeanFactory.java:2043)
	at org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration$DslContextConfiguration.lambda$jooqProvidersDefaultConfigurationCustomizer$5(JooqAutoConfiguration.java:118)
	at org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration$OrderedDefaultConfigurationCustomizer.customize(JooqAutoConfiguration.java:142)
	at org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration$DslContextConfiguration.lambda$jooqConfiguration$1(JooqAutoConfiguration.java:103)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)

Our workaround was to disable JooqAutoConfiguration and configure jOOQ manually.

If there is no easy fix, can you please at least make SpringTransactionProvider overridable (ConditionalOnMissingBean) so we can override just that and not the whole auto-config.

Spring Boot Version: 2.7.5

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 27, 2022
@lukas-krecan lukas-krecan changed the title Clash between jOOQ and Kafka transactoin manager Clash between jOOQ and Kafka transaction manager Oct 27, 2022
@wilkinsona
Copy link
Member

OSS support for Spring Boot 2.5.x ended in May 2022. Please try with Spring Boot 2.6.x or 2.7.x and let us know if the problem still occurs.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Oct 27, 2022
@lukas-krecan
Copy link
Author

lukas-krecan commented Oct 27, 2022

Sorry, it was my fat fingers mistyping. It should have been 2.7.5. Fixed in the description

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 27, 2022
@wilkinsona
Copy link
Member

Perhaps we should make the auto-configured SpringTransactionProvider @ConditionalOnSingleCandidate(PlatformTransactionManager.class) so that it backs off when there's more than one. Flagging for team attention.

@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Oct 27, 2022
@wilkinsona wilkinsona added this to the 2.6.x milestone Oct 27, 2022
@wilkinsona wilkinsona added the type: bug A general bug label Oct 27, 2022
@wilkinsona wilkinsona modified the milestones: 2.6.x, 2.7.x Nov 24, 2022
@philwebb
Copy link
Member

philwebb commented Dec 1, 2022

We're a little worried that @ConditionalOnSingleCandidate would make the error harder to find. We think the best option would be to add @ConditionalOnMissingBean(TransactionProvider.class) to at least allow a custom TransactionProvider to be plugged in.

@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Dec 1, 2022
@philwebb philwebb changed the title Clash between jOOQ and Kafka transaction manager It is not possible to provide a custom TransactionProvider bean Dec 1, 2022
@philwebb philwebb changed the title It is not possible to provide a custom TransactionProvider bean It is not possible to provide a custom TransactionProvider bean for JOOQ Dec 1, 2022
@mhalbritter mhalbritter modified the milestones: 2.7.x, 2.7.8 Jan 12, 2023
krenson pushed a commit to krenson/test-push that referenced this issue Mar 15, 2023
…ot-starter-parent from 2.7.7 to 2.7.8 (patch)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [org.springframework.boot:spring-boot-starter-parent](https://spring.io/projects/spring-boot) ([source](https:/spring-projects/spring-boot)) | parent | patch | `2.7.7` -> `2.7.8` |

---

### Release Notes

<details>
<summary>spring-projects/spring-boot</summary>

### [`v2.7.8`](https:/spring-projects/spring-boot/releases/tag/v2.7.8)

[Compare Source](spring-projects/spring-boot@v2.7.7...v2.7.8)

#### ⭐ Noteworthy

-   The coordinates of the MySQL JDBC driver have [changed from `mysql:mysql-connector-java` to `com.mysql:mysql-connector-j`](https:/spring-projects/spring-boot/wiki/Spring-Boot-2.7-Release-Notes#mysql-jdbc-driver).

#### 🐞 Bug Fixes

-   Devtools sets non-existent property spring.reactor.debug [#&#8203;33858](spring-projects/spring-boot#33858)
-   Failing calls to reactive health indicators are not logged [#&#8203;33774](spring-projects/spring-boot#33774)
-   Failure analysis of NoUniqueBeanDefinitionException reports "defined in null" when bean definition has no resource description [#&#8203;33765](spring-projects/spring-boot#33765)
-   NPE in RabbitProperties when user is given, but password not [#&#8203;33752](spring-projects/spring-boot#33752)
-   SDKMAN should not use repo.spring.io for releases [#&#8203;33708](spring-projects/spring-boot#33708)
-   Homebrew and Scoop should not use repo.spring.io for releases [#&#8203;33702](spring-projects/spring-boot#33702)
-   EndpointRequestMatcher should have a toString method [#&#8203;33690](spring-projects/spring-boot#33690)
-   It is not possible to provide a custom TransactionProvider bean for JOOQ [#&#8203;32899](spring-projects/spring-boot#32899)
-   SpringBootMockResolver causes AopTestUtils.getUltimateTargetObject to recurse until the stack overflows when it calls it with Spring Security's authentication manager bean [#&#8203;32632](spring-projects/spring-boot#32632)
-   Inconsistent discovery of parameter names for selectors in custom actuator endpoints [#&#8203;31240](spring-projects/spring-boot#31240)
-   `@DeprecatedConfigurationProperty` has no effect when declared on a record component's accessor method [#&#8203;29526](spring-projects/spring-boot#29526)
-   Headless mode is forced when banner.\* file is present. [#&#8203;28803](spring-projects/spring-boot#28803)
-   Diagnostics are poor when the JMX port used by the Maven start goal is in use [#&#8203;24044](spring-projects/spring-boot#24044)

#### 📔 Documentation

-   Replace "via" in documentat...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants