-
Notifications
You must be signed in to change notification settings - Fork 1.9k
The error encountered while starting a native image #26386
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
Conversation
…the unused field was removed.
…the unused field was removed.
|
Can one of the admins verify this patch? |
|
Internal PR hazelcast/hazelcast-mono#2803 |
|
Thanks for the reproducer, but it seems to work for me locally? Could this be platform-specific? |
hazelcast/src/main/java/com/hazelcast/instance/BuildInfoProvider.java
Outdated
Show resolved
Hide resolved
No, it is not platform-specific. When you run the native image, you get an error. In other words, it throws an error when the project is starting up. |
author is removed
Seems to work for me with |
Can you run the project with docker run and check if it works correctly? The jar is not a native image. This is why you're not encountering errors. You wouldn't get any errors if you run the jar version of the project. |
Are you able to provide instructions on how to do that, please? |
|
@JackPGreen If you are available, could you also take a look at my other pull request? The two pull requests are related. We worked together up to a certain point. I can explain the issue to you more easily. I can immediately explain the issue to you and show the error with my example code. Additionally, did you encounter the issue as well? Could you provide some information? Thank you very much. |
Import of #26386 **Original PR description:** Hello, In my Spring Boot project, I am using Hazelcast version 5.0.0. It was working without any issues, but I decided to create a native image with GraalVM(Spring Boot Project). I successfully created a native image, but I'm encountering an error during the project startup when running the native image.. Because trying to access a field using reflection, normally this field is registered in a hint for us. However, used reflection to get the field in the code, but you haven't used it. Therefore, this unused field is not registered in the hint. But at runtime, when this field is tried to be accessed using reflection, it causes an error. This is why I created a pull request to remove this code. Alternatively, if you want me to make improvements in another way, I can update my pull request.  If you want to reproduce the error, I am sharing a sample POC project. https://github.com/omercelikceng/native-poc-cache Error : ``` Caused by: java.lang.ExceptionInInitializerError: null at com.hazelcast.spi.properties.ClusterProperty.<clinit>(ClusterProperty.java:1692) ~[na:na] at com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl.<init>(HazelcastClientInstanceImpl.java:232) ~[com.example.NativePocCacheApplication:5.5.0] at com.hazelcast.client.HazelcastClient.constructHazelcastClient(HazelcastClient.java:475) ~[com.example.NativePocCacheApplication:5.5.0] at com.hazelcast.client.HazelcastClient.newHazelcastClientInternal(HazelcastClient.java:425) ~[com.example.NativePocCacheApplication:5.5.0] at com.hazelcast.client.HazelcastClient.newHazelcastClient(HazelcastClient.java:142) ~[com.example.NativePocCacheApplication:5.5.0] at com.example.HazelcastConfiguration.hazelcastClient(HazelcastConfiguration.java:43) ~[com.example.NativePocCacheApplication:na] at com.example.HazelcastConfiguration$$SpringCGLIB$$0.CGLIB$hazelcastClient$1(<generated>) ~[com.example.NativePocCacheApplication:na] at com.example.HazelcastConfiguration$$SpringCGLIB$$FastClass$$1.invoke(<generated>) ~[com.example.NativePocCacheApplication:na] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258) ~[com.example.NativePocCacheApplication:6.1.4] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[na:na] at com.example.HazelcastConfiguration$$SpringCGLIB$$0.hazelcastClient(<generated>) ~[com.example.NativePocCacheApplication:na] at com.example.HazelcastConfiguration__BeanDefinitions.lambda$getHazelcastClientInstanceSupplier$1(HazelcastConfiguration__BeanDefinitions.java:52) ~[na:na] at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68) ~[com.example.NativePocCacheApplication:6.1.4] at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54) ~[com.example.NativePocCacheApplication:6.1.4] at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$2(BeanInstanceSupplier.java:206) ~[na:na] at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58) ~[com.example.NativePocCacheApplication:6.1.4] at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46) ~[com.example.NativePocCacheApplication:6.1.4] at org.springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:218) ~[na:na] at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:206) ~[na:na] at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:949) ~[com.example.NativePocCacheApplication:6.1.4] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1217) ~[com.example.NativePocCacheApplication:6.1.4] ... 33 common frames omitted Caused by: com.hazelcast.core.HazelcastException: java.lang.NoSuchFieldException: ARTIFACT_ID at com.hazelcast.instance.BuildInfoProvider.readStaticStringField(BuildInfoProvider.java:112) ~[na:na] at com.hazelcast.instance.BuildInfoProvider.readBuildPropertiesClass(BuildInfoProvider.java:92) ~[na:na] at com.hazelcast.instance.BuildInfoProvider.getBuildInfoInternalVersion(BuildInfoProvider.java:71) ~[na:na] at com.hazelcast.instance.BuildInfoProvider.populateBuildInfoCache(BuildInfoProvider.java:48) ~[na:na] at com.hazelcast.instance.BuildInfoProvider.<clinit>(BuildInfoProvider.java:41) ~[na:na] ... 54 common frames omitted Caused by: java.lang.NoSuchFieldException: ARTIFACT_ID at [email protected]/java.lang.Class.checkField(DynamicHub.java:1041) ~[com.example.NativePocCacheApplication:na] at [email protected]/java.lang.Class.getField(DynamicHub.java:1026) ~[com.example.NativePocCacheApplication:na] at com.hazelcast.instance.BuildInfoProvider.readStaticStringField(BuildInfoProvider.java:109) ~[na:na] ... 58 common frames omitted ``` Imported changes: - 52d475b When building with native image in Spring, an error was r... - 43b1d17 When building with native image in Spring, an error was r... - cbd80ff Update BuildInfoProvider.java Closes #26386 ORIGINAL_AUTHOR=Ömer Çelik <[email protected]> Co-authored-by: Ömer Çelik <[email protected]> GitOrigin-RevId: 272d80c47a4f723860dcd1610acea90294bbd0da

Hello,
In my Spring Boot project, I am using Hazelcast version 5.0.0. It was working without any issues, but I decided to create a native image with GraalVM(Spring Boot Project). I successfully created a native image, but I'm encountering an error during the project startup when running the native image.. Because trying to access a field using reflection, normally this field is registered in a hint for us. However, used reflection to get the field in the code, but you haven't used it. Therefore, this unused field is not registered in the hint. But at runtime, when this field is tried to be accessed using reflection, it causes an error.
This is why I created a pull request to remove this code. Alternatively, if you want me to make improvements in another way, I can update my pull request.
If you want to reproduce the error, I am sharing a sample POC project.
https://github.com/omercelikceng/native-poc-cache
Error :