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

Hibernate Reactive crashes in Native/AOT native compiled project #2903

Closed
sengokudaikon opened this issue Apr 23, 2024 · 2 comments
Closed
Assignees
Labels
type: bug Something isn't working

Comments

@sengokudaikon
Copy link

sengokudaikon commented Apr 23, 2024

Expected Behavior

Works

Actual Behaviour

Launching a micronaut application with Hibernate Reactive, Kotlin 1.9.23, Kotlin Coroutines causes a crash on startup. Same project, in JVM compiled mode, works as expected.

00:21:33.465 [main] INFO  o.h.r.p.impl.ReactiveIntegrator - HR000001: Hibernate Reactive
00:21:33.561 [vert.x-eventloop-thread-24] INFO  o.h.r.v.impl.DefaultVertxInstance - HR000003: Vert.x instance stopped
00:21:33.561 [main] ERROR i.m.c.h.j.c.AbstractHibernateFactory - Hibernate mapping error
org.hibernate.MappingException: Could not find appropriate constructor for org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister
at org.hibernate.persister.internal.PersisterFactoryImpl.resolveCollectionPersisterConstructor(PersisterFactoryImpl.java:218)
at org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:163)
at org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:155)
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.processBootCollections(MappingMetamodelImpl.java:311)
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:188)
at org.hibernate.internal.SessionFactoryImpl.initializeMappingModel(SessionFactoryImpl.java:364)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:293)
at org.hibernate.reactive.session.impl.ReactiveSessionFactoryImpl.<init>(ReactiveSessionFactoryImpl.java:28)
at org.hibernate.reactive.provider.service.ReactiveSessionFactoryBuilder.build(ReactiveSessionFactoryBuilder.java:38)
at io.micronaut.configuration.hibernate.jpa.conf.AbstractHibernateFactory.buildHibernateSessionFactory(AbstractHibernateFactory.java:105)
at io.micronaut.configuration.hibernate.jpa.conf.SessionFactoryPerJpaConfigurationFactory.buildHibernateSessionFactoryBuilder(SessionFactoryPerJpaConfigurationFactory.java:82)
at io.micronaut.configuration.hibernate.jpa.conf.$SessionFactoryPerJpaConfigurationFactory$BuildHibernateSessionFactoryBuilder4$Definition.instantiate(Unknown Source)
at io.micronaut.context.BeanDefinitionDelegate.instantiate(BeanDefinitionDelegate.java:159)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2311)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2281)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2293)
at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3095)
at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2997)
at io.micronaut.context.DefaultBeanContext.initializeEagerBean(DefaultBeanContext.java:2669)
at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1976)
at io.micronaut.context.DefaultApplicationContext.initializeContext(DefaultApplicationContext.java:294)
at io.micronaut.context.DefaultBeanContext.readAllBeanDefinitionClasses(DefaultBeanContext.java:3348)
at io.micronaut.context.DefaultBeanContext.finalizeConfiguration(DefaultBeanContext.java:3692)
at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:342)
at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:202)
at io.micronaut.runtime.Micronaut.start(Micronaut.java:74)
at io.micronaut.runtime.Micronaut.run(Micronaut.java:328)
at io.micronaut.runtime.Micronaut.run(Micronaut.java:303)
at tech.ararat.cricket.ApplicationKt.main(Application.kt:41)
at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: java.lang.NoSuchMethodException: org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister.<init>(org.hibernate.mapping.Collection, org.hibernate.cache.spi.access.CollectionDataAccess, org.hibernate.metamodel.spi.RuntimeModelCreationContext)
at [email protected]/java.lang.Class.checkMethod(DynamicHub.java:1078)
Caused by: java.lang.NoSuchMethodException: org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister.<init>(org.hibernate.mapping.Collection, org.hibernate.cache.spi.access.CollectionDataAccess, org.hibernate.metamodel.spi.RuntimeModelCreationContext)

at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:1241)
at [email protected]/java.lang.Class.getConstructor(DynamicHub.java:2442)
at org.hibernate.persister.internal.PersisterFactoryImpl.resolveCollectionPersisterConstructor(PersisterFactoryImpl.java:193)
... 30 common frames omitted
00:21:33.562 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Bean definition [org.hibernate.SessionFactory] could not be loaded: Error instantiating bean of type  [org.hibernate.SessionFactory]

Message: Could not find appropriate constructor for org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister
Path Taken: SessionFactoryPerJpaConfigurationFactory.buildHibernateSessionFactoryBuilder(SessionFactoryBuilder sessionFactoryBuilder)
io.micronaut.context.exceptions.BeanInstantiationException: Bean definition [org.hibernate.SessionFactory] could not be loaded: Error instantiating bean of type  [org.hibernate.SessionFactory]

Message: Could not find appropriate constructor for org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister
Path Taken: SessionFactoryPerJpaConfigurationFactory.buildHibernateSessionFactoryBuilder(SessionFactoryBuilder sessionFactoryBuilder)
at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1982)
at io.micronaut.context.DefaultApplicationContext.initializeContext(DefaultApplicationContext.java:294)
at io.micronaut.context.DefaultBeanContext.readAllBeanDefinitionClasses(DefaultBeanContext.java:3348)
at io.micronaut.context.DefaultBeanContext.finalizeConfiguration(DefaultBeanContext.java:3692)
at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:342)
at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:202)
at io.micronaut.runtime.Micronaut.start(Micronaut.java:74)
at io.micronaut.runtime.Micronaut.run(Micronaut.java:328)
at io.micronaut.runtime.Micronaut.run(Micronaut.java:303)
at tech.ararat.cricket.ApplicationKt.main(Application.kt:41)
at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type  [org.hibernate.SessionFactory]

Caused by: io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type  [org.hibernate.SessionFactory]

Message: Could not find appropriate constructor for org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister
Path Taken: SessionFactoryPerJpaConfigurationFactory.buildHibernateSessionFactoryBuilder(SessionFactoryBuilder sessionFactoryBuilder)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2326)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2281)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2293)
at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3095)
at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2997)
at io.micronaut.context.DefaultBeanContext.initializeEagerBean(DefaultBeanContext.java:2669)
at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1976)
... 10 common frames omitted
Caused by: org.hibernate.MappingException: Could not find appropriate constructor for org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister
at org.hibernate.persister.internal.PersisterFactoryImpl.resolveCollectionPersisterConstructor(PersisterFactoryImpl.java:218)
Caused by: org.hibernate.MappingException: Could not find appropriate constructor for org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister

at org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:163)
at org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:155)
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.processBootCollections(MappingMetamodelImpl.java:311)
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:188)
at org.hibernate.internal.SessionFactoryImpl.initializeMappingModel(SessionFactoryImpl.java:364)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:293)
at org.hibernate.reactive.session.impl.ReactiveSessionFactoryImpl.<init>(ReactiveSessionFactoryImpl.java:28)
at org.hibernate.reactive.provider.service.ReactiveSessionFactoryBuilder.build(ReactiveSessionFactoryBuilder.java:38)
at io.micronaut.configuration.hibernate.jpa.conf.AbstractHibernateFactory.buildHibernateSessionFactory(AbstractHibernateFactory.java:105)
at io.micronaut.configuration.hibernate.jpa.conf.SessionFactoryPerJpaConfigurationFactory.buildHibernateSessionFactoryBuilder(SessionFactoryPerJpaConfigurationFactory.java:82)
at io.micronaut.configuration.hibernate.jpa.conf.$SessionFactoryPerJpaConfigurationFactory$BuildHibernateSessionFactoryBuilder4$Definition.instantiate(Unknown Source)
at io.micronaut.context.BeanDefinitionDelegate.instantiate(BeanDefinitionDelegate.java:159)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2311)
... 17 common frames omitted
Caused by: java.lang.NoSuchMethodException: org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister.<init>(org.hibernate.mapping.Collection, org.hibernate.cache.spi.access.CollectionDataAccess, org.hibernate.metamodel.spi.RuntimeModelCreationContext)
at [email protected]/java.lang.Class.checkMethod(DynamicHub.java:1078)
at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:1241)
at [email protected]/java.lang.Class.getConstructor(DynamicHub.java:2442)
at org.hibernate.persister.internal.PersisterFactoryImpl.resolveCollectionPersisterConstructor(PersisterFactoryImpl.java:193)
... (9 lines left)

Steps To Reproduce

any Postgres connection with Hibernate Reactive, any dependencies beside it, some JPA Entites containing collections

Environment Information

macOSX Sonoma 14.1.1, Docker v24.0.7, GraalVM 21.0.3

Example Application

Reproducer

Version

4.4.0

@radovanradic
Copy link
Contributor

@sengokudaikon, thanks for figuring out that this is failing for @ManyToMany and @ElementCollection annotated fields.
Looks like shared graalvm metadata repository is missing this for hibernate-reactive

{
        "name": "org.hibernate.reactive.persister.collection.impl.ReactiveBasicCollectionPersister",
        "methods": [
            {
                "name": "<init>",
                "parameterTypes": [
                    "org.hibernate.mapping.Collection",
                    "org.hibernate.cache.spi.access.CollectionDataAccess",
                    "org.hibernate.metamodel.spi.RuntimeModelCreationContext"
                ]
            }
        ]
    }

so we will add this first to data-hibernate-reactive and then later to the shared repository.

@radovanradic
Copy link
Contributor

Merged PR #2919 that should fix this issue and
created another PR in oracle/graalvm-reachability-metadata that will add metadata to shared repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants