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 3.1.0 native build (windows exe) won't start #35569

Closed
ghost opened this issue May 19, 2023 · 9 comments
Closed

Spring boot 3.1.0 native build (windows exe) won't start #35569

ghost opened this issue May 19, 2023 · 9 comments

Comments

@ghost
Copy link

ghost commented May 19, 2023

Environment:
Windows 11
spring-boot: 3.1.0
kotlin: 1.8.21
native-gradle-plugin: 0.9.22
graalvm: graalvm-ce-java19-22.3.1

Bug description:
native compile ends without errors, but when starting the exe version, an error occurs:

com.oracle.svm.core.jdk.UnsupportedFeatureError: No classes have been predefined during the image build to load from bytecodes at runtime.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89) ~[na:na]
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.PredefinedClassesSupport.throwNoBytecodeClasses(PredefinedClassesSupport.java:76) ~[na:na]
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.PredefinedClassesSupport.loadClass(PredefinedClassesSupport.java:130) ~[na:na]

Regression:
works fine with spring-boot 3.0.7 and exactly the same environment and code

with each new spring-boot version, the native build does not work !?!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 19, 2023
@wilkinsona
Copy link
Member

This looks like a duplicate of spring-projects/spring-framework#30492. Can you please try with 6.0.10-SNAPSHOT of Spring Framework that is available for https://repo.spring.io/snapshot.

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

ghost commented May 21, 2023

an error occurs with the patch:
Caused by: java.lang.IllegalArgumentException: Invalid logger interface org.hibernate.dialect.DialectLogging (implementation not found in jdk.internal.loader.ClassLoaders$AppClassLoader@45c8e616)

which is related probably with oracle/graal#5626 and/or oracle/graal#6526

I will start to cry

@ghost ghost closed this as not planned Won't fix, can't repro, duplicate, stale May 21, 2023
@wilkinsona wilkinsona 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 May 22, 2023
@edeandrea
Copy link

Confirming I'm seeing the same thing described in this issue and that upgrading spring framework version to 6.0.10-SNAPSHOT produces the following error when running in native:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': null
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1156) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:931) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[springboot3-todo:3.1.0]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733) ~[springboot3-todo:3.1.0]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435) ~[springboot3-todo:3.1.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[springboot3-todo:3.1.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) ~[springboot3-todo:3.1.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294) ~[springboot3-todo:3.1.0]
        at com.example.Application.main(Application.java:16) ~[springboot3-todo:na]
Caused by: java.lang.ExceptionInInitializerError: null
        at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.logSelectedDialect(DialectFactoryImpl.java:93) ~[springboot3-todo:6.2.2.Final]
        at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:88) ~[springboot3-todo:6.2.2.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:224) ~[na:na]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:34) ~[na:na]
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:119) ~[na:na]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) ~[springboot3-todo:6.2.2.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:239) ~[springboot3-todo:6.2.2.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:216) ~[springboot3-todo:6.2.2.Final]
        at org.hibernate.boot.model.relational.Database.<init>(Database.java:45) ~[na:na]
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:229) ~[springboot3-todo:6.2.2.Final]
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:197) ~[springboot3-todo:6.2.2.Final]
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:166) ~[na:na]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1380) ~[na:na]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1451) ~[na:na]
        at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:74) ~[na:na]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816) ~[springboot3-todo:6.0.10-SNAPSHOT]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[springboot3-todo:6.0.10-SNAPSHOT]
        ... 16 common frames omitted
Caused by: java.lang.IllegalArgumentException: Invalid logger interface org.hibernate.dialect.DialectLogging (implementation not found in jdk.internal.loader.ClassLoaders$AppClassLoader@3ecf72fd)
        at org.jboss.logging.Logger.doGetMessageLogger(Logger.java:2564) ~[springboot3-todo:3.5.0.Final]
        at org.jboss.logging.Logger.getMessageLogger(Logger.java:2530) ~[springboot3-todo:3.5.0.Final]
        at org.jboss.logging.Logger.getMessageLogger(Logger.java:2516) ~[springboot3-todo:3.5.0.Final]
        at org.hibernate.dialect.DialectLogging.<clinit>(DialectLogging.java:31) ~[na:na]
        ... 37 common frames omitted

@wilkinsona
Copy link
Member

That should be addressed by oracle/graalvm-reachability-metadata@4629271.

@edeandrea
Copy link

Thank you @wilkinsona . Is there a way for me to pull that into one of my projects?

@wilkinsona
Copy link
Member

IIRC, the documentation for the NBT Maven and Gradle plugins describes how to override the metadata version that's used.

@edeandrea
Copy link

Thank you again. Using Spring Framework 6.0.10-SNAPSHOT with the graalvm-reachability-metadata 0.3.1 does not fix the problem (still produces the error I posted above). I'll wait for a new Spring Boot version that will hopefully resolve it.

@wilkinsona
Copy link
Member

Waiting is unlikely to result in a fix. If Hibernate's unable to load a type reflectively, that will have to be addressed in the reachability metadata. You many want to report the problem there.

@edeandrea
Copy link

I can do that and blindly copy/paste this error there/configuration there, but I'm not really sure/familiar with what the reachability metadata even is. All I know is that my Spring Boot 3.1 app doesn't work because of something under the covers, which from my perspective is a black box.

This issue was closed.
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

3 participants