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

[Native Image] ImportBeanDefinitionRegistrar not load the bean #10277

Open
1 task
tadlakha9 opened this issue Dec 10, 2024 · 10 comments
Open
1 task

[Native Image] ImportBeanDefinitionRegistrar not load the bean #10277

tadlakha9 opened this issue Dec 10, 2024 · 10 comments
Assignees

Comments

@tadlakha9
Copy link

tadlakha9 commented Dec 10, 2024

Describe the Issue

We have a scenario where we are loading a bean using a custom annotation with the help of ImportBeanDefinitionRegistrar but bean is not loaded and we are getting below exception

image

Gradle bootRun task is working fine.

We have generated an executable(working fine), now while running the executable we are getting the issue, we are using graalvm 17. Facing the same issue with graalvm 21 and graalvm 23

Please find the reproducer.

practice.zip

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

java version "17.0.13" 2024-10-15 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 17.0.13+10.1 (build 17.0.13+10-LTS-jvmci-23.0-b49)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.13+10.1 (build 17.0.13+10-LTS-jvmci-23.0-b49, mixed mode, sharing)

Operating System and Version

Linux 4.18.0-372.105.1.el8_6.x86_64 #1 SMP x86_64 GNU/Linux

Build Command

gradle nativeRun

Expected Behavior

our expectation is that the bean to be loaded while using ImportBeanDefinitionRegistrar

Actual Behavior

executable is generated perfectly fine, issue only while running the executable.

Steps to Reproduce

  1. gradle nativeRun : this is the command we can use to reproduce the issue.

Additional Context

No response

Build Log Output and Error Messages


APPLICATION FAILED TO START


Description:

Parameter 0 of constructor in com.example.practice.service.CustomerService required a bean of type 'com.example.practice.client.CustomerClient' that could not be found.

Action:

Consider defining a bean of type 'com.example.practice.client.CustomerClient' in your configuration.

@selhagani
Copy link
Member

Hi @tadlakha9,
Thank you for reaching out to us!

Could you please try generating the metadata configuration files using the tracing agent? This could solve the issue that you're facing.
I see that you're using gradle so this documentation should help you.

@tadlakha9
Copy link
Author

Hello @selhagani

Thanks for replying.

yes we have followed the mentioned document and generate the metadata configuration file using the tracing agent, we have placed the generated reflect-config.json file inside \src\main\resources\META-INF\native-image and also added some more configuration which was not added by tracing agent automatically, but the error didn't resolve.

@selhagani
Copy link
Member

I'm afraid I can't use the zip file you attached as a reproducer to investigate this issue any further. Could you please add your reproducer to a github repo and share it with me please?

@tadlakha9
Copy link
Author

I'm afraid I can't use the zip file you attached as a reproducer to investigate this issue any further. Could you please add your reproducer to a github repo and share it with me please?

Here you can find the reproducer

@selhagani
Copy link
Member

When trying to reproduce the issue I got the following error:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
I am using Gradle 8.11.1
Perhaps we are using different Gradle versions?

@tadlakha9
Copy link
Author

tadlakha9 commented Dec 12, 2024

we are using gradle 8.8 version but i think the issue you are referring to is just a warning not going to hamper anything.

@selhagani
Copy link
Member

Hi @tadlakha9,
Yes I managed to reproduce the issue that you're facing as well.
You told me that you tried adding the missing configuration even after using the tracing agent. Did you follow the steps specified here? If not then could you please try doing so? this can tell us if this issue is linked to a Missing Metadata Registration or not.

@tadlakha9
Copy link
Author

i have tried to pass the arguments as below

image

but i am getting an issue that it is unrecognized, don't know if i am doing something wrong.

image

@tadlakha9
Copy link
Author

tadlakha9 commented Dec 17, 2024

@selhagani Did you find anything else which needs to be further analyzed

@selhagani
Copy link
Member

You can just add "-H:ThrowMissingRegistrationErrors=true" to your config file instead of "--exact-reachability-metadata=com.example.practive" after that you can run the native-image executable while passing the following command "-XX:MissingRegistrationReportingMode=Warn".

Also I am actively working on this on my end and I'll make sure to keep you updated once I find something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants