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

Micronaut jOOQ tries to inject mulitple possible bean(Configuration) candidates #1292

Open
sc-etranet opened this issue Feb 26, 2024 · 1 comment

Comments

@sc-etranet
Copy link

Expected Behavior

I have pretty basic Micronaut app(4.3.2, java 17 and kotlin) and I wanted to try jdbc, r2dbc, flyway, test-resources and project reactor just as a proof of concept. When I try to start the test in which I use my SimpleRepository I'm presented with the message below(stacktrace in 'Actual behaviour' section). SimpleRepository is injecting DslContext.

Expected behaviour:
DSLContext bean should be injected without the error and repository methods should return data.

Actual Behaviour

DSLContext is not properly injected, instead the exception is thrown and repository is not returning the data.

13:20:59.086 [default-nioEventLoopGroup-1-2] ERROR i.m.http.server.RouteExecutor - Unexpected error occurred: Failed to inject value for parameter [configuration] of method [dslContext] of class: io.micronaut.configuration.jooq.DSLContextFactory

Message: Multiple possible bean candidates found: [Configuration, Configuration]
Path Taken: new SimpleController(SimpleRepository simpleRepository) --> new SimpleController([SimpleRepository simpleRepository]) --> new SimpleRepository([DSLContext dslContext]) --> DSLContextFactory.dslContext([Configuration configuration])
io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for parameter [configuration] of method [dslContext] of class: io.micronaut.configuration.jooq.DSLContextFactory

Message: Multiple possible bean candidates found: [Configuration, Configuration]
Path Taken: new SimpleController(SimpleRepository simpleRepository) --> new SimpleController([SimpleRepository simpleRepository]) --> new SimpleRepository([DSLContext dslContext]) --> DSLContextFactory.dslContext([Configuration configuration])
	at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2181)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Assembly trace from producer [reactor.core.publisher.MonoFlatMap] :
	reactor.core.publisher.Mono.flatMap(Mono.java:3116)
	io.micronaut.http.reactive.execution.ReactorExecutionFlowImpl.flatMap(ReactorExecutionFlowImpl.java:59)
Error has been observed at the following site(s):
	*__Mono.flatMap ⇢ at io.micronaut.http.reactive.execution.ReactorExecutionFlowImpl.flatMap(ReactorExecutionFlowImpl.java:59)
Original Stack Trace:
		at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2181)
		at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1328)
		at io.micronaut.configuration.jooq.$DSLContextFactory$DslContext0$Definition.instantiate(Unknown Source)
		at io.micronaut.context.BeanDefinitionDelegate.instantiate(BeanDefinitionDelegate.java:159)
		at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2330)
		at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2300)
		at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2312)
		at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3114)
		at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
		at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3016)
		at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2977)
		at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2751)
		at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1750)
		at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
		at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2165)
		at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1328)
		at com.example.$SimpleRepository$Definition.instantiate(Unknown Source)
		at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2330)
		at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2300)
		at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2312)
		at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3114)
		at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
		at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3016)
		at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2977)
		at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2751)
		at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1750)
		at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
		at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2165)
		at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1328)
		at com.example.$SimpleController$Definition.instantiate(Unknown Source)
		at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2330)
		at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2300)
		at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2312)
		at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3114)
		at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
		at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3016)
		at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2977)
		at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2951)
		at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1716)
		at io.micronaut.context.DefaultBeanContext$BeanContextExecutionHandle.getTarget(DefaultBeanContext.java:4307)
		at io.micronaut.context.DefaultBeanContext$BeanContextUnsafeExecutionHandle.invokeUnsafe(DefaultBeanContext.java:4274)
		at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:230)
		at io.micronaut.http.server.RouteExecutor.executeRouteAndConvertBody(RouteExecutor.java:488)
		at io.micronaut.http.server.RouteExecutor.callRoute(RouteExecutor.java:476)
		at io.micronaut.http.server.RequestLifecycle.callRoute(RequestLifecycle.java:201)
		at io.micronaut.http.server.RequestLifecycle.executeRoute(RequestLifecycle.java:191)
		at io.micronaut.http.server.RequestLifecycle.lambda$normalFlow$1(RequestLifecycle.java:181)
		at io.micronaut.http.filter.FilterRunner.provideResponse(FilterRunner.java:272)
		at io.micronaut.http.filter.FilterRunner.filterRequest(FilterRunner.java:207)
		at io.micronaut.http.filter.FilterRunner.run(FilterRunner.java:158)
		at io.micronaut.http.filter.FilterRunner.run(FilterRunner.java:135)
		at io.micronaut.http.server.RequestLifecycle.runWithFilters(RequestLifecycle.java:357)
		at io.micronaut.http.server.RequestLifecycle.normalFlow(RequestLifecycle.java:181)
		at io.micronaut.http.server.netty.NettyRequestLifecycle.handleNormal(NettyRequestLifecycle.java:88)
		at io.micronaut.http.server.netty.RoutingInBoundHandler.accept(RoutingInBoundHandler.java:227)
		at io.micronaut.http.server.netty.websocket.NettyServerWebSocketUpgradeHandler.accept(NettyServerWebSocketUpgradeHandler.java:156)
		at io.micronaut.http.server.netty.handler.PipeliningServerHandler$MessageInboundHandler.read(PipeliningServerHandler.java:388)
		at io.micronaut.http.server.netty.handler.PipeliningServerHandler.channelRead(PipeliningServerHandler.java:213)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
		at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
		at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.onHttpRequestChannelRead(WebSocketServerExtensionHandler.java:160)
		at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:83)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
		at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
		at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
		at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
		at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
		at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:289)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
		at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
		at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
		at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
		at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
		at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
		at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
		at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
		at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
		at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
		at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
		at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: io.micronaut.context.exceptions.NonUniqueBeanException: Multiple possible bean candidates found: [Configuration, Configuration]
	at io.micronaut.context.DefaultBeanContext.findConcreteCandidate(DefaultBeanContext.java:2449)
Caused by: io.micronaut.context.exceptions.NonUniqueBeanException: Multiple possible bean candidates found: [Configuration, Configuration]

	at io.micronaut.context.DefaultApplicationContext.findConcreteCandidate(DefaultApplicationContext.java:634)
	at io.micronaut.context.DefaultBeanContext.lastChanceResolve(DefaultBeanContext.java:3272)
	at io.micronaut.context.DefaultBeanContext.pickOneBean(DefaultBeanContext.java:3216)
	at io.micronaut.context.DefaultBeanContext.findConcreteCandidateNoCache(DefaultBeanContext.java:3172)
	at io.micronaut.context.DefaultBeanContext.findConcreteCandidate(DefaultBeanContext.java:3155)
	at io.micronaut.context.DefaultBeanContext.findBeanDefinition(DefaultBeanContext.java:2766)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2741)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1750)
	at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
	at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2165)
	at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1328)
	at io.micronaut.configuration.jooq.$DSLContextFactory$DslContext0$Definition.instantiate(Unknown Source)
	at io.micronaut.context.BeanDefinitionDelegate.instantiate(BeanDefinitionDelegate.java:159)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2330)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2300)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2312)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3114)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3016)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2977)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2751)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1750)
	at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
	at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2165)
	at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1328)
	at com.example.$SimpleRepository$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2330)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2300)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2312)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3114)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3016)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2977)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2751)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1750)
	at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
	at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2165)
	at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1328)
	at com.example.$SimpleController$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2330)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2300)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2312)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3114)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3016)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2977)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2951)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1716)
	at io.micronaut.context.DefaultBeanContext$BeanContextExecutionHandle.getTarget(DefaultBeanContext.java:4307)
	at io.micronaut.context.DefaultBeanContext$BeanContextUnsafeExecutionHandle.invokeUnsafe(DefaultBeanContext.java:4274)
	at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:230)
	at io.micronaut.http.server.RouteExecutor.executeRouteAndConvertBody(RouteExecutor.java:488)
	at io.micronaut.http.server.RouteExecutor.callRoute(RouteExecutor.java:476)
	at io.micronaut.http.server.RequestLifecycle.callRoute(RequestLifecycle.java:201)
	at io.micronaut.http.server.RequestLifecycle.executeRoute(RequestLifecycle.java:191)
	at io.micronaut.http.server.RequestLifecycle.lambda$normalFlow$1(RequestLifecycle.java:181)
	at io.micronaut.http.filter.FilterRunner.provideResponse(FilterRunner.java:272)
	at io.micronaut.http.filter.FilterRunner.filterRequest(FilterRunner.java:207)
	at io.micronaut.http.filter.FilterRunner.run(FilterRunner.java:158)
	at io.micronaut.http.filter.FilterRunner.run(FilterRunner.java:135)
	at io.micronaut.http.server.RequestLifecycle.runWithFilters(RequestLifecycle.java:357)
	at io.micronaut.http.server.RequestLifecycle.normalFlow(RequestLifecycle.java:181)
	at io.micronaut.http.server.netty.NettyRequestLifecycle.handleNormal(NettyRequestLifecycle.java:88)
	at io.micronaut.http.server.netty.RoutingInBoundHandler.accept(RoutingInBoundHandler.java:227)
	at io.micronaut.http.server.netty.websocket.NettyServerWebSocketUpgradeHandler.accept(NettyServerWebSocketUpgradeHandler.java:156)
	at io.micronaut.http.server.netty.handler.PipeliningServerHandler$MessageInboundHandler.read(PipeliningServerHandler.java:388)
	at io.micronaut.http.server.netty.handler.PipeliningServerHandler.channelRead(PipeliningServerHandler.java:213)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
	at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.onHttpRequestChannelRead(WebSocketServerExtensionHandler.java:160)
	at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:83)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:289)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:833)

Steps To Reproduce

  1. On dev/test environment
  2. With default config initialized from Micronaut initializer
  3. Either run gradle run and hit endpoint http://localhost:8080/simple or start test method testIfRepositoryWorks in class DemoR2dbcJava17Test
  4. See the error in console, it should be similar to one posted in previous section.

Environment Information

  • Operating system - Linux - ubuntu 22.04
  • Java - open jdk 17.0.9

Example Application

https://github.com/sc-etranet/demo-r2dbc-java17

Version

4.3.2

@tstelar
Copy link

tstelar commented Feb 29, 2024

It seems that one solution to disambiguate multiple Configuration instances in this case would be something like the following (using only R2DBC connection in injected DSLContexts), which would still allow liquibase/flyway migrations to work, along with Micronaut Test Resources:

import io.micronaut.context.annotation.Bean
import io.micronaut.context.annotation.Factory
import io.micronaut.context.annotation.Replaces
import io.r2dbc.spi.ConnectionFactory
import jakarta.inject.Named
import org.jooq.Configuration
import org.jooq.DSLContext
import org.jooq.impl.DSL
import org.jooq.impl.DefaultConfiguration
import javax.sql.DataSource

@Factory
class JooqFactory {
    @Bean
    @Named("r2dbcConfig")
    fun r2dbcConfig(
        datasource: DataSource,
        r2dbcConnectionFactory: ConnectionFactory
    ) = DefaultConfiguration()
        .set(datasource)
        .set(r2dbcConnectionFactory)
        .set(org.jooq.SQLDialect.POSTGRES)

    @Bean
    @Replaces(DSLContext::class)
    fun jooqDslContext(
        @Named("r2dbcConfig")
        configuration: Configuration
    ) = DSL.using(configuration)
}

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

No branches or pull requests

2 participants