This happens on native image generation with rc6 (but not rc5):
...
Caused by: java.lang.NullPointerException
at com.oracle.svm.hosted.analysis.Inflation.checkType(Inflation.java:139)
at java.lang.Iterable.forEach(Iterable.java:75)
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080)
at com.oracle.svm.hosted.analysis.Inflation.checkObjectGraph(Inflation.java:130)
at com.oracle.graal.pointsto.BigBang.checkObjectGraph(BigBang.java:590)
at com.oracle.graal.pointsto.BigBang.finish(BigBang.java:562)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:690)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:401)
...
Source code with README: https://github.com/dsyer/spring-boot-micro-apps (master branch, BuncApplication main class).
I have the same error while compiling Spring Fu Graal sample webapp which works with RC5. Sadly this regression makes RC6 unusable for Spring webapps. Any chance to fix this on master in order to allow us to move forward?
Thanks for reporting. We will fix this asap. Maybe we can use the Spring Fu Graal sample webapp in our regression testing - what is the license on the code?
Sure feel free to do so, it is licensed under Apache.
Spring Fu code base moves a lot, so I am not sure it will be easy for you to use it, but I will provide you tomorrow a minimal Boot sample project with current other issues workaround that you will be able to use easily for regression testing.
OK, excellent, that would be great!
Please find the repro project in https://github.com/sdeleuze/spring-boot-graal-demo, it is Apache 2 licensed. Notice this is not yet a typical Boot app because I can't use @Configuration scanning due to #630. I will create branches for other issues asap this blocking regression will be solved.
I have pushed a new commit that should avoid to hit https://github.com/oracle/graal/issues/564 with GraalVM 1.0.0.RC5
@sdeleuze thank you! Update: this regression is only a problem for apps that have incomplete class paths. I am working on it but a proper solution will take more time. Once this is fixed I will add your example app to our internal gate.
Do you know what is the missing dependency in this case (this is not obvious from the error message)?
@sdeleuze for the original issue reported by @dsyer the problem is in SpringApplication.isWebApplicationContext:
private boolean isWebApplicationContext(Class<?> applicationContextClass) {
try {
return WebApplicationContext.class.isAssignableFrom(applicationContextClass);
}
catch (NoClassDefFoundError ex) {
return false;
}
}
WebApplicationContext uses javax.servlet.ServletContext which is not on the classpath.
This is reached via:
at org.springframework.boot.SpringApplication.setApplicationContextClass(SpringApplication.java:1178)
at com.example.func.BuncApplication.run(BuncApplication.java:54)
at com.example.func.BuncApplication.main(BuncApplication.java:34)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:163)
We get the same NoClassDefFoundError, which on the JVM is gracefully ignored, during the image building when calling Class.getDeclaredMethods() on WebApplicationContext.class which leads to some inconsistent state which leads to the NPE.
(I haven't looked in the Spring Fu failure yet.)
I have been able to work around this with AspectJ. You can weave an aspect at runtime into the Graal native image generator that catches the exception and swallows it. It's the same issue in Fu and the same workaround would work. IMO this needs to be fixed here though.
@dsyer yes, we plan to fully support apps with incomplete class paths as it looks like major Java frameworks use this approach. It just proves to be more difficult than we initially thought.
This issue is solved by --allow-incomplete-classpath and can be closed.
Most helpful comment
Sure feel free to do so, it is licensed under Apache.