question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE in native-image when running quarkus-maven-plugin on CLI

See original GitHub issue

I’d like to experiment with some options to GraalVM’s native-image, so I naively looked at this output:

[INFO] --- shamrock-maven-plugin:0.1.0:native-image (default) @ shamrock-quickstart ---
[INFO] Running Shamrock native-image plugin on OpenJDK 64-Bit Server VM
[/home/vorburger/bin/graalvm-ce-1.0.0-rc10/bin/native-image, -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager, -J-Dcom.sun.xml.internal.bind.v2.bytecode.ClassTailor.noOptimize=true, -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime, -jar, shamrock-quickstart-1.0-SNAPSHOT-runner.jar, -J-Djava.util.concurrent.ForkJoinPool.common.parallelism=1, -H:+PrintAnalysisCallTree, -H:EnableURLProtocols=http, -H:-JNI, --no-server, -H:-UseServiceLoaderFeature, -H:+StackTrace]

and copy/paste that, ditching the commas, and adding target/ before the JAR to run from e.g. protean-quickstarts/getting-started-native instead of inside target, like so:

$ /home/vorburger/bin/graalvm-ce-1.0.0-rc10/bin/native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dcom.sun.xml.internal.bind.v2.bytecode.ClassTailor.noOptimize=true -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar target/shamrock-quickstart-1.0-SNAPSHOT-runner.jar -J-Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -H:+PrintAnalysisCallTree -H:EnableURLProtocols=http -H:-JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace

but this just leads to this NPE in Graal VM, does anyone happen to know what I’m missing:

[shamrock-quickstart-1.0-SNAPSHOT-runner:27789]    classlist:   3,389.04 ms
[shamrock-quickstart-1.0-SNAPSHOT-runner:27789]        setup:      94.18 ms
fatal error: java.lang.NullPointerException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598)
	at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:418)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:278)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:375)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:104)
Caused by: java.lang.NullPointerException
	at com.oracle.graal.pointsto.reports.CallTreePrinter.buildCallTree(CallTreePrinter.java:155)
	at com.oracle.graal.pointsto.reports.CallTreePrinter.print(CallTreePrinter.java:61)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:764)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:401)
	at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Image building with exit status 1

Perhaps the shamrock-maven-plugin could be made to print out the exact command it runs?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
vorburgercommented, Dec 17, 2018

The strange behaviour is being caused by the way the native image binary is parsing the command line args

duh! Right. It’s probably my shell (zsh) that interpolated $BySpaceAndTime as an (empty) env var; sorry.

If you use the argument, -H:InitialCollectionPolicy=‘com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime’ it builds without error.

Indeed, I got it working now.

This is something that has changed between RC9 and RC10 of graalVM

I’m using RC10. In order to truly make the mojo provide a copiable-pasteable version, I guess in an ideal world, further to b952a5c, it should add ' escapes to args (only if they contain $ ?) but you would probably have to put it around every “pair” (second) of args to avoid this issue.

1reaction
johnaoharacommented, Dec 17, 2018

The InitialCollectionPolicy sets the GC collector for substrateVM. The strange behaviour is being caused by the way the native image binary is parsing the command line args. It is trying to instantiate com.oracle.svm.core.genscavenge.CollectionPolicy, which is a abstract class, instead of com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime

If you use the argument, -H:InitialCollectionPolicy=‘com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime’ it builds without error.

This is something that has changed between RC9 and RC10 of graalVM

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building applications with Maven - Quarkus
To run Integration Tests on the native executable, make sure to have the proper Maven plugin configured (see Maven configuration) and launch the...
Read more >
graalvm/native-image - Gitter
First the native-image complained it did not understood the --no-server flag (passed presumably by the Quarkus Maven plugin?)
Read more >
Watch GraalVM Turn Your Java Into Binaries - Okta Developer
GraalVM's native-image tool converts a Java application into a ... Run the example with the Exec Maven Plugin: mvn compile exec:java :
Read more >
chore(deps): update dependency io.quarkus:quarkus ... - GitLab
chore(deps): update dependency io.quarkus:quarkus-maven-plugin to v2.
Read more >
dplatz.de - notes of a java developer
You see, that quarkus.http.auth.permission.permit1 gives full access all ... Finally, run your native-image build from a Command-prompt.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found