Skip to content

NullPointerException in Inflation.checkType() #655

Closed

Description

@dsyer

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

Activity

  1. sdeleuze commented on Sep 4, 2018

    @sdeleuze
    Collaborator

    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?

  2. thomaswue commented on Sep 4, 2018

    @thomaswue
    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?

  3. sdeleuze commented on Sep 4, 2018

    @sdeleuze
    Collaborator

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

  4. self-assigned this
    on Sep 4, 2018
  5. sdeleuze commented on Sep 5, 2018

    @sdeleuze
    Collaborator

    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.

  6. thomaswue commented on Sep 5, 2018

    @thomaswue
    Member

    OK, excellent, that would be great!

  7. sdeleuze commented on Sep 6, 2018

    @sdeleuze
    Collaborator

    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.

  8. sdeleuze commented on Sep 6, 2018

    @sdeleuze
    Collaborator

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

  9. cstancu commented on Sep 6, 2018

    @cstancu
    Member

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

  10. sdeleuze commented on Sep 7, 2018

    @sdeleuze
    Collaborator

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

  11. cstancu commented on Sep 7, 2018

    @cstancu
    Member

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

  12. dsyer commented on Sep 7, 2018

    @dsyer
    Author

    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.

  13. cstancu commented on Sep 7, 2018

    @cstancu
    Member

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

  14. sdeleuze commented on Nov 11, 2018

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions