Skip to content

Fail to run AOT process step on native build #4248

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

Closed
guillaume-1 opened this issue Dec 5, 2022 · 3 comments
Closed

Fail to run AOT process step on native build #4248

guillaume-1 opened this issue Dec 5, 2022 · 3 comments
Assignees
Labels
type: bug A general bug

Comments

@guillaume-1
Copy link

Hi,

I tried to build a native image from a Spring Boot 3.0.0 project (Webflux based on Netty, Mongo reactive)
I've already created an issue on springboot project, but the error seems to be generated by spring data class : org.springframework.data.util.TypeContributor
Here my compile stacktrace with "gradle nativeCompile" command:

Task :processAot


/ \ | ____ | | _ _ __ ___ | |()/ () ___ __ | |() ___ _ __ ___
\ | |/ / | | | | | | '_ \ / _ \| __| | |_| |/ __/ _ | _| |/ _ | ' / __|
\ \ < (| | | |
| | | | | | () | || | | | (| (| | || | () | | | _
_/|__,||_, | || ||_/ _||| ||__,|_||_/|| ||/
|
__/

2022-12-04T11:41:48.834+01:00 INFO 45852 --- [ main] c.skaly.notifications.SkalyNotification : Starting SkalyNotification using Java 17.0.5 with PID 45852 (/Users/guillaumemartial/projects/skaly/skaly-notifications/build/classes/java/main started by guillaumemartial in /Users/guillaumemartial/projects/skaly/skaly-notifications)
2022-12-04T11:41:48.837+01:00 INFO 45852 --- [ main] c.skaly.notifications.SkalyNotification : The following 1 profile is active: "dev"
2022-12-04T11:41:49.305+01:00 INFO 45852 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive MongoDB repositories in DEFAULT mode.
2022-12-04T11:41:49.405+01:00 INFO 45852 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 96 ms. Found 6 Reactive MongoDB repository interfaces.
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because the return value of "java.lang.Class.getCanonicalName()" is null
at org.springframework.aot.hint.BindingReflectionHintsRegistrar.shouldSkipMembers(BindingReflectionHintsRegistrar.java:74)
at org.springframework.aot.hint.BindingReflectionHintsRegistrar.lambda$registerReflectionHints$0(BindingReflectionHintsRegistrar.java:87)
at org.springframework.aot.hint.ReflectionHints.registerType(ReflectionHints.java:86)
at org.springframework.aot.hint.ReflectionHints.registerType(ReflectionHints.java:109)
at org.springframework.aot.hint.BindingReflectionHintsRegistrar.registerReflectionHints(BindingReflectionHintsRegistrar.java:86)
at org.springframework.aot.hint.BindingReflectionHintsRegistrar.registerReflectionHints(BindingReflectionHintsRegistrar.java:65)
at org.springframework.data.util.TypeContributor.contribute(TypeContributor.java:70)
at org.springframework.data.repository.config.RepositoryRegistrationAotProcessor.contributeType(RepositoryRegistrationAotProcessor.java:171)
at org.springframework.data.repository.config.RepositoryRegistrationAotProcessor.lambda$contribute$1(RepositoryRegistrationAotProcessor.java:85)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at org.springframework.data.repository.config.RepositoryRegistrationAotProcessor.contribute(RepositoryRegistrationAotProcessor.java:85)
at org.springframework.data.mongodb.repository.aot.AotMongoRepositoryPostProcessor.contribute(AotMongoRepositoryPostProcessor.java:35)
at org.springframework.data.repository.config.RepositoryRegistrationAotContribution.lambda$applyTo$0(RepositoryRegistrationAotContribution.java:253)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at org.springframework.data.repository.config.RepositoryRegistrationAotContribution.applyTo(RepositoryRegistrationAotContribution.java:253)
at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.lambda$generateBeanDefinitionMethod$2(BeanDefinitionMethodGenerator.java:179)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:178)
at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:102)
at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$generateRegisterBeanDefinitionsMethod$2(BeanRegistrationsAotContribution.java:85)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.generateRegisterBeanDefinitionsMethod(BeanRegistrationsAotContribution.java:83)
at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.lambda$applyTo$1(BeanRegistrationsAotContribution.java:67)
at org.springframework.aot.generate.GeneratedMethod.(GeneratedMethod.java:54)
at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:112)
at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:89)
at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.applyTo(BeanRegistrationsAotContribution.java:66)
at org.springframework.context.aot.BeanFactoryInitializationAotContributions.applyTo(BeanFactoryInitializationAotContributions.java:78)
at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58)
at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:76)

Task :processAot FAILED

Can you help me please ?
Thanks.

Guillaume

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 5, 2022
@christophstrobl
Copy link
Member

Could you please share a minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. That would help us spot the issue.

@christophstrobl christophstrobl added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 5, 2022
@guillaume-1
Copy link
Author

Sure @christophstrobl
You can reproduce it running : ./gradlew build on this attached repo
skaly-native-test.zip
Note that I had to add implementation 'org.mongodb:mongo-java-driver:3.12.11' to avoid this at the same build step : java.lang.ClassNotFoundException: com.mongodb.client.MongoCollection
But this causes conflicts with spring data mongo dependencies at runtime.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 5, 2022
@christophstrobl
Copy link
Member

thanks @guillaume-1 - will have a look!

@christophstrobl christophstrobl self-assigned this Dec 5, 2022
mp911de pushed a commit that referenced this issue Jan 12, 2023
…ion.

In some cases the users domain model may hold references to spring data or MongoDB specific types which should not be included in the reflection configuration as they are part of the static runtime hints configuration.

Closes #4248
Original pull request: #4249
mp911de added a commit that referenced this issue Jan 12, 2023
Add missing package-info.

See #4248
Original pull request: #4249
mp911de added a commit that referenced this issue Jan 12, 2023
Add missing package-info.

See #4248
Original pull request: #4249
@mp911de mp911de added type: bug A general bug and removed status: feedback-provided Feedback has been provided labels Jan 12, 2023
@mp911de mp911de added this to the 4.0.1 (2022.0.1) milestone Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
4 participants