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

Error instantiating bean of type [io.vertx.rxjava3.sqlclient.Pool] #1496

Closed
hantsy opened this issue Nov 19, 2024 · 2 comments
Closed

Error instantiating bean of type [io.vertx.rxjava3.sqlclient.Pool] #1496

hantsy opened this issue Nov 19, 2024 · 2 comments

Comments

@hantsy
Copy link

hantsy commented Nov 19, 2024

Issue description

I created a custom bean to avoid the issue reported in #1333, it worked well.

@Factory
public class PoolFactory {

    @Bean
    public Pool rx3Pool(io.vertx.sqlclient.Pool pool) {
        return new Pool(pool);
    }
}

The complete example project is here, https://github.com/hantsy/micronaut-sandbox/tree/master/rxjava3-vertx-pg-client.

But in the latest Micronaut, it failed with an exception like this:

Error instantiating bean of type  [io.vertx.rxjava3.sqlclient.Pool]

Message: 'void io.vertx.core.impl.CloseFuture.add(io.vertx.core.Closeable)'
Path Taken: new PostRepository(Pool client) --> new PostRepository([Pool client]) --> PoolFactory.rx3Pool([Pool pool])
io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type  [io.vertx.rxjava3.sqlclient.Pool]

Message: 'void io.vertx.core.impl.CloseFuture.add(io.vertx.core.Closeable)'
Path Taken: new PostRepository(Pool client) --> new PostRepository([Pool client]) --> PoolFactory.rx3Pool([Pool pool])
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2349)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2304)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2316)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3127)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3029)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2990)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2756)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1745)
	at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
	at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2188)
	at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1350)
	at com.example.$PoolFactory$Rx3Pool0$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2334)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2304)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2316)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3127)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:3017)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2756)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1745)
	at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
	at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2188)
	at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1350)
	at com.example.$PostRepository$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2334)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2304)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2316)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3127)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3029)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2990)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2756)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1745)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:842)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:834)
	at com.example.PostRepositoryTest.setup(PostRepositoryTest.java:69)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.NoSuchMethodError: 'void io.vertx.core.impl.CloseFuture.add(io.vertx.core.Closeable)'
	at io.vertx.sqlclient.impl.PoolImpl.init(PoolImpl.java:88)
	at io.vertx.pgclient.spi.PgDriver.newPoolImpl(PgDriver.java:48)
	at io.vertx.pgclient.spi.PgDriver.newPool(PgDriver.java:38)
	at io.vertx.sqlclient.spi.Driver.createPool(Driver.java:68)
	at io.vertx.sqlclient.spi.Driver.createPool(Driver.java:100)
	at io.micronaut.configuration.vertx.pg.client.PgDriverFactory.build(PgDriverFactory.java:67)
	at io.micronaut.configuration.vertx.pg.client.$PgDriverFactory$Build0$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2334)
	... 38 more


'void io.vertx.core.impl.CloseFuture.add(io.vertx.core.Closeable)'
java.lang.NoSuchMethodError: 'void io.vertx.core.impl.CloseFuture.add(io.vertx.core.Closeable)'
	at io.vertx.sqlclient.impl.PoolImpl.init(PoolImpl.java:88)
	at io.vertx.pgclient.spi.PgDriver.newPoolImpl(PgDriver.java:48)
	at io.vertx.pgclient.spi.PgDriver.newPool(PgDriver.java:38)
	at io.vertx.sqlclient.spi.Driver.createPool(Driver.java:68)
	at io.vertx.sqlclient.spi.Driver.createPool(Driver.java:100)
	at io.micronaut.configuration.vertx.pg.client.PgDriverFactory.build(PgDriverFactory.java:67)
	at io.micronaut.configuration.vertx.pg.client.$PgDriverFactory$Build0$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2334)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2304)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2316)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3127)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3029)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2990)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2756)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1745)
	at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
	at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2188)
	at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1350)
	at com.example.$PoolFactory$Rx3Pool0$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2334)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2304)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2316)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3127)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:3017)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2756)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1745)
	at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
	at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2188)
	at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1350)
	at com.example.$PostRepository$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2334)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2304)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2316)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3127)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3029)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2990)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2756)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1745)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:842)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:834)
	at com.example.PostRepositoryTest.setup(PostRepositoryTest.java:69)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
@radovanradic
Copy link
Contributor

Looking at your dependencies you have this
implementation("io.vertx:vertx-rx-java3:4.5.11")
and vertx versions coming from micronaut-sql are 4.5.10 and this is probably causing incompatibilities. If you change it to
implementation("io.vertx:vertx-rx-java3:4.5.10") then it might get resolved.

@hantsy
Copy link
Author

hantsy commented Nov 27, 2024

Yes, it fixed the issue.

@hantsy hantsy closed this as completed Nov 27, 2024
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