java - Exception encountered during context initialization on Start spring native application - Stack Overflow

I am trying to setup my existing Springboot v3.4.1 project running on Java 17 to work with GraalVM 23.0

I am trying to setup my existing Springboot v3.4.1 project running on Java 17 to work with GraalVM 23.0.7.r17-nik

After efforts, I am able to build the project executable, but on executing,

./target/fcr

It fails with exception: w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: .springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor': BeanPostProcessor before instantiation of bean failed Application run failed

The exact trace is as follows:

 w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: .springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor': BeanPostProcessor before instantiation of bean failed
Application run failed
.springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor': BeanPostProcessor before instantiation of bean failed
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:518)
        at .springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
        at .springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
        at .springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
        at .springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
        at .springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:277)
        at .springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:808)
        at .springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:611)
        at .springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
        at .springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
        at .springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
        at .springframework.boot.SpringApplication.run(SpringApplication.java:318)
        at .springframework.boot.SpringApplication.run(SpringApplication.java:1361)
        at .springframework.boot.SpringApplication.run(SpringApplication.java:1350)
        at com.xxxxxx.yyy.CompanyConfigApplication.main(CompanyConfigApplication.java:14)
Caused by: .springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '.springframework.transaction.config.internalTransactionAdvisor': Unsatisfied dependency expressed through method 'transactionAdvisor' parameter 0: Error creating bean with name '.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Class .springframework.core.annotation.TypeMappedAnnotation[] is instantiated reflectively but was never registered.Register the class by adding "unsafeAllocated" for the class in reflect-config.json.
        at .springframework.beans.factory.aot.BeanInstanceSupplier.resolveAutowiredArgument(BeanInstanceSupplier.java:369)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:289)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:223)
        at .springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:979)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1239)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1182)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
        at .springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
        at .springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
        at .springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
        at .springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
        at .springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91)
        at .springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:119)
        at .springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92)
        at .springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:105)
        at .springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:280)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1150)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1125)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:512)
        ... 14 more
Caused by: .springframework.beans.factory.BeanCreationException: Error creating bean with name '.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Class .springframework.core.annotation.TypeMappedAnnotation[] is instantiated reflectively but was never registered.Register the class by adding "unsafeAllocated" for the class in reflect-config.json.
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
        at .springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
        at .springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
        at .springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
        at .springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
        at .springframework.transaction.annotation.ProxyTransactionManagementConfiguration__BeanDefinitions.lambda$getTransactionAttributeSourceInstanceSupplier$2(ProxyTransactionManagementConfiguration__BeanDefinitions.java:75)
        at .springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:63)
        at .springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:51)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$1(BeanInstanceSupplier.java:219)
        at .springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
        at .springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:258)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:219)
        at .springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:979)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1239)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1182)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
        at .springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
        at .springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
        at .springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
        at .springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at .springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1573)
        at .springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1519)
        at .springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913)
        at .springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:253)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.resolveAutowiredArgument(BeanInstanceSupplier.java:366)
        ... 33 more
Caused by: java.lang.IllegalArgumentException: Class .springframework.core.annotation.TypeMappedAnnotation[] is instantiated reflectively but was never registered.Register the class by adding "unsafeAllocated" for the class in reflect-config.json.
        at .graalvm.nativeimage.builder/com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets.arrayHubErrorStub(SubstrateAllocationSnippets.java:351)
        at .springframework.core.type.classreading.MergedAnnotationReadingVisitor$ArrayVisitor.visitEnd(MergedAnnotationReadingVisitor.java:183)
        at .springframework.asm.ClassReader.readElementValues(ClassReader.java:3023)
        at .springframework.asm.ClassReader.readElementValue(ClassReader.java:3193)
        at .springframework.asm.ClassReader.readElementValues(ClassReader.java:3013)
        at .springframework.asm.ClassReader.accept(ClassReader.java:611)
        at .springframework.asm.ClassReader.accept(ClassReader.java:427)
        at .springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:48)
        at .springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
        at .springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:131)
        at .springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
        at .springframework.context.annotation.ImportAwareAotBeanPostProcessor.setAnnotationMetadata(ImportAwareAotBeanPostProcessor.java:70)
        at .springframework.context.annotation.ImportAwareAotBeanPostProcessor.postProcessBeforeInitialization(ImportAwareAotBeanPostProcessor.java:54)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:423)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
        ... 60 more

I tried setting TypeMappedAnnotation as buildArg, but it didn't work.

<buildArg>--initialize-at-build-time=.springframework.core.annotation.TypeMappedAnnotation</buildArg>

I have also tried setting src/main/resources/META-INF/native-image/reflect-config.json with mentioned json as suggested in stacktrace, but it is still failing with same exception.

[
  {
    "name": ".springframework.core.annotation.TypeMappedAnnotation",
    "unsafeAllocated": true
  }
]

Any suggestions, how I can fix this?

I am trying to setup my existing Springboot v3.4.1 project running on Java 17 to work with GraalVM 23.0.7.r17-nik

After efforts, I am able to build the project executable, but on executing,

./target/fcr

It fails with exception: w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: .springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor': BeanPostProcessor before instantiation of bean failed Application run failed

The exact trace is as follows:

 w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: .springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor': BeanPostProcessor before instantiation of bean failed
Application run failed
.springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor': BeanPostProcessor before instantiation of bean failed
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:518)
        at .springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
        at .springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
        at .springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
        at .springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
        at .springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:277)
        at .springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:808)
        at .springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:611)
        at .springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
        at .springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
        at .springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
        at .springframework.boot.SpringApplication.run(SpringApplication.java:318)
        at .springframework.boot.SpringApplication.run(SpringApplication.java:1361)
        at .springframework.boot.SpringApplication.run(SpringApplication.java:1350)
        at com.xxxxxx.yyy.CompanyConfigApplication.main(CompanyConfigApplication.java:14)
Caused by: .springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '.springframework.transaction.config.internalTransactionAdvisor': Unsatisfied dependency expressed through method 'transactionAdvisor' parameter 0: Error creating bean with name '.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Class .springframework.core.annotation.TypeMappedAnnotation[] is instantiated reflectively but was never registered.Register the class by adding "unsafeAllocated" for the class in reflect-config.json.
        at .springframework.beans.factory.aot.BeanInstanceSupplier.resolveAutowiredArgument(BeanInstanceSupplier.java:369)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:289)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:223)
        at .springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:979)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1239)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1182)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
        at .springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
        at .springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
        at .springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
        at .springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
        at .springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91)
        at .springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:119)
        at .springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92)
        at .springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:105)
        at .springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:280)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1150)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1125)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:512)
        ... 14 more
Caused by: .springframework.beans.factory.BeanCreationException: Error creating bean with name '.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Class .springframework.core.annotation.TypeMappedAnnotation[] is instantiated reflectively but was never registered.Register the class by adding "unsafeAllocated" for the class in reflect-config.json.
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
        at .springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
        at .springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
        at .springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
        at .springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
        at .springframework.transaction.annotation.ProxyTransactionManagementConfiguration__BeanDefinitions.lambda$getTransactionAttributeSourceInstanceSupplier$2(ProxyTransactionManagementConfiguration__BeanDefinitions.java:75)
        at .springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:63)
        at .springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:51)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$1(BeanInstanceSupplier.java:219)
        at .springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
        at .springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:258)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:219)
        at .springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:979)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1239)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1182)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
        at .springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
        at .springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289)
        at .springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
        at .springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at .springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1573)
        at .springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1519)
        at .springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913)
        at .springframework.beans.factory.support.RegisteredBean.resolveAutowiredArgument(RegisteredBean.java:253)
        at .springframework.beans.factory.aot.BeanInstanceSupplier.resolveAutowiredArgument(BeanInstanceSupplier.java:366)
        ... 33 more
Caused by: java.lang.IllegalArgumentException: Class .springframework.core.annotation.TypeMappedAnnotation[] is instantiated reflectively but was never registered.Register the class by adding "unsafeAllocated" for the class in reflect-config.json.
        at .graalvm.nativeimage.builder/com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets.arrayHubErrorStub(SubstrateAllocationSnippets.java:351)
        at .springframework.core.type.classreading.MergedAnnotationReadingVisitor$ArrayVisitor.visitEnd(MergedAnnotationReadingVisitor.java:183)
        at .springframework.asm.ClassReader.readElementValues(ClassReader.java:3023)
        at .springframework.asm.ClassReader.readElementValue(ClassReader.java:3193)
        at .springframework.asm.ClassReader.readElementValues(ClassReader.java:3013)
        at .springframework.asm.ClassReader.accept(ClassReader.java:611)
        at .springframework.asm.ClassReader.accept(ClassReader.java:427)
        at .springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:48)
        at .springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
        at .springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:131)
        at .springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
        at .springframework.context.annotation.ImportAwareAotBeanPostProcessor.setAnnotationMetadata(ImportAwareAotBeanPostProcessor.java:70)
        at .springframework.context.annotation.ImportAwareAotBeanPostProcessor.postProcessBeforeInitialization(ImportAwareAotBeanPostProcessor.java:54)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:423)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
        at .springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
        ... 60 more

I tried setting TypeMappedAnnotation as buildArg, but it didn't work.

<buildArg>--initialize-at-build-time=.springframework.core.annotation.TypeMappedAnnotation</buildArg>

I have also tried setting src/main/resources/META-INF/native-image/reflect-config.json with mentioned json as suggested in stacktrace, but it is still failing with same exception.

[
  {
    "name": ".springframework.core.annotation.TypeMappedAnnotation",
    "unsafeAllocated": true
  }
]

Any suggestions, how I can fix this?

Share Improve this question edited Mar 10 at 19:36 Vibhor Verma asked Mar 10 at 18:55 Vibhor VermaVibhor Verma 1831 gold badge4 silver badges15 bronze badges 2
  • Have you tried the suggestion from the stack trace? –Class .springframework.core.annotation.TypeMappedAnnotation[] is instantiated reflectively but was never registered. Register the class by adding "unsafeAllocated" for the class in reflect-config.json." – what happens when you add it to reflect-config.json? – knittl Commented Mar 10 at 19:00
  • @knittl I have set TypeMappedAnnotation with "unsafeAllocated" as true, but still it is failing with same exception. Added details in description about this. – Vibhor Verma Commented Mar 10 at 19:33
Add a comment  | 

1 Answer 1

Reset to default 0

I found solution in Github repo's issues that these problems are caused by DataBaseConfiguration class that configures database, entity manager factory and transaction manager by hand. This is not really supported by Spring Native. So I configured it based on JPA-based builders.

Github Repo: https://github/spring-attic/spring-native/issues/1665

DataBaseConfiguration class sample as in solution given in mentioned Github Issues: https://github/mhalbritter/spring-native-issue-1665/blob/main/src/main/java/com/a1s/discovery/config/datasource/PersistencePostgresAutoConfiguration.java

This solved my problem.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744829033a4595972.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信