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

NullPointerException in Inflation.checkType() #655

Closed
dsyer opened this issue Sep 4, 2018 · 13 comments
Closed

NullPointerException in Inflation.checkType() #655

dsyer opened this issue Sep 4, 2018 · 13 comments
Assignees

Comments

@dsyer
Copy link

dsyer commented Sep 4, 2018

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).

@sdeleuze
Copy link
Collaborator

sdeleuze commented Sep 4, 2018

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?

@thomaswue
Copy link
Member

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?

@sdeleuze
Copy link
Collaborator

sdeleuze commented Sep 4, 2018

Sure feel free to do so, it is licensed under Apache.

@cstancu cstancu self-assigned this Sep 4, 2018
@sdeleuze
Copy link
Collaborator

sdeleuze commented Sep 5, 2018

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.

@thomaswue
Copy link
Member

OK, excellent, that would be great!

@sdeleuze
Copy link
Collaborator

sdeleuze commented Sep 6, 2018

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.

@sdeleuze
Copy link
Collaborator

sdeleuze commented Sep 6, 2018

I have pushed a new commit that should avoid to hit #564 with GraalVM 1.0.0.RC5

@cstancu
Copy link
Member

cstancu commented Sep 6, 2018

@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.

@sdeleuze
Copy link
Collaborator

sdeleuze commented Sep 7, 2018

Do you know what is the missing dependency in this case (this is not obvious from the error message)?

@cstancu
Copy link
Member

cstancu commented Sep 7, 2018

@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.)

@dsyer
Copy link
Author

dsyer commented Sep 7, 2018

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.

@cstancu
Copy link
Member

cstancu commented Sep 7, 2018

@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.

@sdeleuze
Copy link
Collaborator

This issue is solved by --allow-incomplete-classpath and can be closed.

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

5 participants