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

Spring Boot native application fails at startup #36031

Closed
rkudryashov opened this issue Jun 22, 2023 · 3 comments
Closed

Spring Boot native application fails at startup #36031

rkudryashov opened this issue Jun 22, 2023 · 3 comments
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@rkudryashov
Copy link

Version: 3.1.1

Log:

2023-06-22T15:24:58.120Z  INFO 1 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "public": 1.0.1
2023-06-22T15:24:58.120Z  INFO 1 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "public" is up to date. No migration necessary.
2023-06-22T15:24:58.124Z  INFO 1 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-06-22T15:24:58.125Z  INFO 1 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.2.5.Final
2023-06-22T15:24:58.125Z  WARN 1 --- [           main] org.hibernate.orm.deprecation            : HHH90000029: The [hibernate.bytecode.use_reflection_optimizer] configuration is deprecated and will be removed. Set the value to [true] to get rid of this warning
2023-06-22T15:24:58.148Z  INFO 1 --- [           main] o.h.b.i.BytecodeProviderInitiator        : HHH000021: Bytecode provider name : none
2023-06-22T15:24:58.149Z ERROR 1 --- [           main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Could not instantiate generator of type 'org.hibernate.generator.internal.CurrentTimestampGeneration'
2023-06-22T15:24:58.149Z  WARN 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Could not instantiate generator of type 'org.hibernate.generator.internal.CurrentTimestampGeneration'
2023-06-22T15:24:58.149Z  INFO 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2023-06-22T15:24:58.159Z  INFO 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2023-06-22T15:24:58.159Z  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-06-22T15:24:58.159Z ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Could not instantiate generator of type 'org.hibernate.generator.internal.CurrentTimestampGeneration'
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:931) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:3.1.1]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:3.1.1]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:3.1.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:3.1.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:3.1.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:3.1.1]
        at com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt.main(BookServiceApplication.kt:34) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:na]
Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.HibernateException: Could not instantiate generator of type 'org.hibernate.generator.internal.CurrentTimestampGeneration'
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:421) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        ... 16 common frames omitted
Caused by: org.hibernate.HibernateException: Could not instantiate generator of type 'org.hibernate.generator.internal.CurrentTimestampGeneration'
        at org.hibernate.boot.model.internal.GeneratorBinder.instantiateGenerator(GeneratorBinder.java:425) ~[na:na]
        at org.hibernate.boot.model.internal.GeneratorBinder.lambda$generatorCreator$0(GeneratorBinder.java:362) ~[na:na]
        at org.hibernate.mapping.Property.createGenerator(Property.java:482) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.2.5.Final]
        at org.hibernate.tuple.entity.EntityMetamodel.buildGenerator(EntityMetamodel.java:479) ~[na:na]
        at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:313) ~[na:na]
        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:499) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.2.5.Final]
        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:140) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.2.5.Final]
        at java.base@17.0.7/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:na]
        at java.base@17.0.7/java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:na]
        at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:92) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.2.5.Final]
        at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:75) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.2.5.Final]
        at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.processBootEntities(MappingMetamodelImpl.java:247) ~[na:na]
        at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:185) ~[na:na]
        at org.hibernate.internal.SessionFactoryImpl.initializeMappingModel(SessionFactoryImpl.java:320) ~[na:na]
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:270) ~[na:na]
        at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:431) ~[na:na]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1455) ~[na:na]
        at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) ~[na:na]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:6.0.10]
        ... 20 common frames omitted
Caused by: java.lang.InstantiationException: org.hibernate.generator.internal.CurrentTimestampGeneration
        at java.base@17.0.7/java.lang.Class.newInstance(DynamicHub.java:639) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:na]
        at org.hibernate.boot.model.internal.GeneratorBinder.instantiateGenerator(GeneratorBinder.java:419) ~[na:na]
        ... 39 common frames omitted
Caused by: java.lang.NoSuchMethodException: org.hibernate.generator.internal.CurrentTimestampGeneration.<init>()
        at java.base@17.0.7/java.lang.Class.getConstructor0(DynamicHub.java:3585) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:na]
        at java.base@17.0.7/java.lang.Class.newInstance(DynamicHub.java:626) ~[com.romankudryashov.outboxinbox.bookservice.BookServiceApplicationKt:na]
        ... 40 common frames omitted

It looks to me that it can be caused by usage of timestamp annotations:

@MappedSuperclass
abstract class AbstractEntity(
    @JsonIgnore
    @CreationTimestamp
    val createdAt: LocalDateTime? = null,

    @JsonIgnore
    @UpdateTimestamp
    val updatedAt: LocalDateTime? = null
)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 22, 2023
@mhalbritter mhalbritter added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-feedback We need additional information before we can continue labels Jun 22, 2023
@wilkinsona
Copy link
Member

It looks like some reflection hints for org.hibernate.generator.internal.CurrentTimestampGeneration are missing. Please open a reachability metadata issue for that. You should be able to work around the problem by providing some hints yourself. You could either use a reflect-config.json file or Spring Framework's runtime hints mechanism.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jun 22, 2023
@rkudryashov
Copy link
Author

oracle/graalvm-reachability-metadata#323

@rkudryashov rkudryashov closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2023
@mhalbritter mhalbritter added status: invalid An issue that we don't feel is valid for: external-project For an external project and not something we can fix and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Jun 23, 2023
@wilkinsona
Copy link
Member

Thanks, @rkudryashov.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants