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 when using 0.9.12 and later to run tests with native image compilation #270

Closed
mpeddada1 opened this issue Jul 20, 2022 · 4 comments · Fixed by #274
Closed
Assignees
Labels
bug Something isn't working maven-plugin Related to Maven plugin

Comments

@mpeddada1
Copy link

mpeddada1 commented Jul 20, 2022

Describe the bug
Running a simple test with native-maven-plugin 0.9.12 and later is resulting a NullPointerException at build time.

To Reproduce
Reproduce: https://github.com/mpeddada1/junit-testrule

Expected behavior
The tests run successfully with the versions in question.

Logs
Following the steps in the README of the reproducer is resulting in this stacktrace:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.MySampleTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.028 s - in com.example.MySampleTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- native-maven-plugin:0.9.13:test (test-native) @ child-project ---
[INFO] ====================
[INFO] Initializing project: child-project
[INFO] ====================
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.770 s
[INFO] Finished at: 2022-07-20T17:43:43-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.13:test (test-native) on project child-project: Execution test-native of goal org.graalvm.buildtools:native-maven-plugin:0.9.13:test failed.: NullPointerException -> [Help 1]

Snippet of stacktrace with -X flag

However, note that this test runs successfully with 0.9.11

System Info (please complete the following information):

  • OS: Linux
  • GraalVM Version: 22.1.0 CE
  • Java Version: 11
  • Plugin version: native-maven-plugin 0.9.12 and 0.9.13

I'm wondering if anyone has run into this problem? Thank you!

cc @suztomo @meltsufin

@mpeddada1 mpeddada1 added the bug Something isn't working label Jul 20, 2022
@suztomo
Copy link

suztomo commented Jul 20, 2022

Can you run the Maven command with "-X" (debug) and copy-paste it in https://gist.github.com ?

@mpeddada1
Copy link
Author

Yes, I've edited the issue description above to include a snippet of the stacktrace determine from -X.

@suztomo
Copy link

suztomo commented Jul 21, 2022

Nice. It shows the exact line number that hit NullPointerException. Let's wait for the maintainers.

Caused by: java.lang.NullPointerException
    at org.graalvm.buildtools.maven.AbstractNativeMojo.processArtifact (AbstractNativeMojo.java:285)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.getMainBuildPath (AbstractNativeMojo.java:351)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.populateApplicationClasspath (AbstractNativeMojo.java:361)
    at org.graalvm.buildtools.maven.NativeTestMojo.populateApplicationClasspath (NativeTestMojo.java:88)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.populateClasspath (AbstractNativeMojo.java:372)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.getClasspath (AbstractNativeMojo.java:378)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.getBuildArgs (AbstractNativeMojo.java:211)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.buildImage (AbstractNativeMojo.java:393)
    at org.graalvm.buildtools.maven.NativeTestMojo.execute (NativeTestMojo.java:149)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

@alvarosanchez alvarosanchez added the maven-plugin Related to Maven plugin label Jul 21, 2022
lazar-mitrovic added a commit to lazar-mitrovic/native-build-tools that referenced this issue Jul 24, 2022
lazar-mitrovic added a commit to lazar-mitrovic/native-build-tools that referenced this issue Jul 24, 2022
Allow running native:build from the command-line graalvm#273
NullPointerException fix graalvm#270
lazar-mitrovic added a commit to lazar-mitrovic/native-build-tools that referenced this issue Jul 27, 2022
Allow running native:build from the command-line graalvm#273 (TODO: fix samples)
NullPointerException fix graalvm#270

Signed-off-by: Lazar Mitrović <lazar.mitrovic@oracle.com>
lazar-mitrovic added a commit to lazar-mitrovic/native-build-tools that referenced this issue Aug 1, 2022
Allow running native:build from the command-line graalvm#273 (TODO: fix samples)
NullPointerException fix graalvm#270
Rename Mojos (use native:compile from the command line)

Signed-off-by: Lazar Mitrović <lazar.mitrovic@oracle.com>
lazar-mitrovic added a commit to lazar-mitrovic/native-build-tools that referenced this issue Aug 1, 2022
Allow running native:build from the command-line graalvm#273 (TODO: fix samples)
NullPointerException fix graalvm#270
Rename Mojos (use native:compile from the command line)

Signed-off-by: Lazar Mitrović <lazar.mitrovic@oracle.com>
@zliu9125
Copy link

zliu9125 commented Aug 2, 2022

Also come across this case. And I found that when adding <packaging>pom</packaging> and other necessary spring-native plugins to the pom of pure springboot project generated at https://start.spring.io/ and then run mvn -Pnative -DskipTests clean package may reproduce this issue.

lazar-mitrovic added a commit to lazar-mitrovic/native-build-tools that referenced this issue Aug 4, 2022
Allow running native:build from the command-line graalvm#273
NullPointerException fix graalvm#270
Rename Mojos (use native:compile from the command line)

Signed-off-by: Lazar Mitrović <lazar.mitrovic@oracle.com>
@lazar-mitrovic lazar-mitrovic self-assigned this Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working maven-plugin Related to Maven plugin
5 participants