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

Test binary fails to build #288

Closed
gfmedeiros opened this issue Aug 15, 2022 · 3 comments
Closed

Test binary fails to build #288

gfmedeiros opened this issue Aug 15, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@gfmedeiros
Copy link

Describe the bug
The Maven plugin fails when when trying to build a native test binary. Building the actual binary works as expected.

To Reproduce
Use this reproducer.

Expected behavior
The test binary should be built successfully.

Logs

➜  graalvm-native-build-tools-bug git:(main) ./mvnw -Pnative test                                  
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< com.example:example >-------------------------
[INFO] Building example 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ example ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /home/gabriel/graalvm-native-build-tools-bug/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ example ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ example ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /home/gabriel/graalvm-native-build-tools-bug/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ example ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M7:test (default-test) @ example ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.ExampleTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.046 s - in com.example.ExampleTest
[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) @ example ---
[INFO] ====================
[INFO] Initializing project: example
[INFO] ====================
[INFO] Found GraalVM installation from GRAALVM_HOME variable.
[INFO] ImageClasspath Entry: com.example:example:jar:1.0-SNAPSHOT (file:///home/gabriel/graalvm-native-build-tools-bug/target/classes/)
[WARNING] Artifact `/home/gabriel/graalvm-native-build-tools-bug/target/classes` is a directory.
[INFO] ImageClasspath Entry: org.junit.jupiter:junit-jupiter-api:jar:5.9.0:test (file:///home/gabriel/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.9.0/junit-jupiter-api-5.9.0.jar)
[INFO] ImageClasspath Entry: org.junit.platform:junit-platform-engine:jar:1.9.0:test (file:///home/gabriel/.m2/repository/org/junit/platform/junit-platform-engine/1.9.0/junit-platform-engine-1.9.0.jar)
[INFO] ImageClasspath Entry: org.opentest4j:opentest4j:jar:1.2.0:test (file:///home/gabriel/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar)
[INFO] ImageClasspath Entry: org.junit.platform:junit-platform-commons:jar:1.9.0:test (file:///home/gabriel/.m2/repository/org/junit/platform/junit-platform-commons/1.9.0/junit-platform-commons-1.9.0.jar)
[INFO] ImageClasspath Entry: org.apiguardian:apiguardian-api:jar:1.1.2:test (file:///home/gabriel/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar)
[INFO] ImageClasspath Entry: org.junit.jupiter:junit-jupiter-engine:jar:5.9.0:test (file:///home/gabriel/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.9.0/junit-jupiter-engine-5.9.0.jar)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.947 s
[INFO] Finished at: 2022-08-15T20:12:51-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.13:test (test-native) on project example: Execution test-native of goal org.graalvm.buildtools:native-maven-plugin:0.9.13:test failed: A required class was missing while executing org.graalvm.buildtools:native-maven-plugin:0.9.13:test: org/graalvm/nativeimage/hosted/Feature
[ERROR] -----------------------------------------------------
[ERROR] realm =    extension>org.graalvm.buildtools:native-maven-plugin:0.9.13
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/gabriel/.m2/repository/org/graalvm/buildtools/native-maven-plugin/0.9.13/native-maven-plugin-0.9.13.jar
[ERROR] urls[1] = file:/home/gabriel/.m2/repository/org/graalvm/buildtools/junit-platform-native/0.9.13/junit-platform-native-0.9.13.jar
[ERROR] urls[2] = file:/home/gabriel/.m2/repository/org/junit/platform/junit-platform-console/1.8.1/junit-platform-console-1.8.1.jar
[ERROR] urls[3] = file:/home/gabriel/.m2/repository/org/junit/platform/junit-platform-reporting/1.8.1/junit-platform-reporting-1.8.1.jar
[ERROR] urls[4] = file:/home/gabriel/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar
[ERROR] urls[5] = file:/home/gabriel/.m2/repository/org/junit/platform/junit-platform-launcher/1.8.1/junit-platform-launcher-1.8.1.jar
[ERROR] urls[6] = file:/home/gabriel/.m2/repository/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar
[ERROR] urls[7] = file:/home/gabriel/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar
[ERROR] urls[8] = file:/home/gabriel/.m2/repository/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar
[ERROR] urls[9] = file:/home/gabriel/.m2/repository/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar
[ERROR] urls[10] = file:/home/gabriel/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar
[ERROR] urls[11] = file:/home/gabriel/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar
[ERROR] urls[12] = file:/home/gabriel/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar
[ERROR] urls[13] = file:/home/gabriel/.m2/repository/org/graalvm/buildtools/utils/0.9.13/utils-0.9.13.jar
[ERROR] urls[14] = file:/home/gabriel/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.3/jackson-databind-2.13.3.jar
[ERROR] urls[15] = file:/home/gabriel/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.3/jackson-annotations-2.13.3.jar
[ERROR] urls[16] = file:/home/gabriel/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.3/jackson-core-2.13.3.jar
[ERROR] urls[17] = file:/home/gabriel/.m2/repository/org/graalvm/buildtools/graalvm-reachability-metadata/0.9.13/graalvm-reachability-metadata-0.9.13.jar
[ERROR] urls[18] = file:/home/gabriel/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] : org.graalvm.nativeimage.hosted.Feature
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

System Info (please complete the following information):

  • OS: Linux Mint 20.3
  • GraalVM Version 22.1.0.0.r17-mandrel
  • Java Version 17
  • Plugin version native-gradle-plugin:0.9.13
@gfmedeiros gfmedeiros added the bug Something isn't working label Aug 15, 2022
@lazar-mitrovic
Copy link
Collaborator

Hi @gfmedeiros,
This issue originates from svm.jar missing from the classpath during the plugin run.
You should be able to easily workaround that by setting JAVA_HOME=$GRAALVM_HOME.

As this is not that convenient, we actually added an explicit implementation dependency on svm.jar in this commit. That change will land in 0.9.14.

I'll close this issue, but feel free to comment if you have some other questions.
Fixed by #274

@gfmedeiros
Copy link
Author

Hi @lazar-mitrovic,

The error still happens if I point JAVA_HOME and GRAALVM_HOME to the same GraalVM JDK.

@lazar-mitrovic
Copy link
Collaborator

Hm that shouldn't happen...
I had a similar thing happen to me locally, and if I remember correctly it was an issue with SDKMAN installed JDKs being auto detected by Maven Toolchain support. Running mvn with -X might be useful for debugging this.

If you are able to build the latest version from master that would solve your problem, as we now pin both java executable and sdk dependency. We are still working on fixing our snapshot publishing CI task, so unfortunately there is no nice and quick way to check that out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
2 participants