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

Nullpointer Exception with native app since 2.3.0 #485

Closed
ctschubel opened this issue Aug 22, 2023 · 13 comments
Closed

Nullpointer Exception with native app since 2.3.0 #485

ctschubel opened this issue Aug 22, 2023 · 13 comments

Comments

@ctschubel
Copy link

There are no issues when I build a native executable of my app using version 2.2.0.

When i tried to update to 2.3.0 I got following errors on startup:

ERROR: Failed to start application (with profile [prod])
java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
Caused by: java.lang.NullPointerException
	at io.quarkiverse.googlecloudservices.common.GcpDefaultsConfigSourceFactory.getConfigSources(GcpDefaultsConfigSourceFactory.java:27)
	at io.smallrye.config.ConfigurableConfigSource.getConfigSources(ConfigurableConfigSource.java:50)
	at io.smallrye.config.SmallRyeConfig$ConfigSources.mapLateSources(SmallRyeConfig.java:669)
	at io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(SmallRyeConfig.java:553)
	at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:69)
	at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:629)
	at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
	at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
	... 7 more

I guess the newly introduced class io.quarkiverse.googlecloudservices.common.GcpDefaultsConfigSourceFactory is causing the problems.

if (Converters.getImplicitConverter(Boolean.class).convert(enableMetadataServer.getValue())) {

There are no issues when I build a jar and start it.

@loicmathieu
Copy link
Collaborator

@ctschubel thanks for reporting the issue, can you provide a reproducer project?

@ctschubel
Copy link
Author

Thanks for the reply!
I build a small maven project to reproduce the issue. It has only an application class, one service that connects to firestore and a restcontroller. They are not needed anyway, the issue occurs when the project is build and started.
I attached it to this comment.

I build it like this:

cd ./issue-485/

# use local graalVM
export GRAALVM_HOME=${pathToGraalHome}/mandrel-java17-22.3.2.1-Final

# build project as native executable
mvn clean install -Pnative

And I just start the executable:

cd ./target
./issue-485-0.0.1-SNAPSHOT-runner

issue-485.tar.gz

@loicmathieu
Copy link
Collaborator

loicmathieu commented Aug 24, 2023

This looks like a bug in GraalVM native image.

java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1

[...]

undefined reference to `Java_com_sun_management_internal_OperatingSystemImpl_initialize0'
collect2: error: ld returned 1 exit status
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageViaCC.handleLinkerFailure(NativeImageViaCC.java:204)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageViaCC.runLinkerCommand(NativeImageViaCC.java:151)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageViaCC.write(NativeImageViaCC.java:117)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:724)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:539)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:408)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:612)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:134)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:94)

@loicmathieu
Copy link
Collaborator

Same as #482

@ctschubel
Copy link
Author

I'm not sure if it actually is the same issue...

I wasn't able to build the application with the remote docker container quarkus.native.remote-container-build=true at all, neither with version 2.2.0 nor with 2.3.0.
If i try it i get the exception you mentioned.

I guess thats because the remote containers uses an other version of graalVM, the build log says:

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Checking status of builder image 'quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-17'
jdk-17: Pulling from quarkus/ubi-quarkus-mandrel-builder-image
Digest: sha256:18494105bcb5fc549e59e00daee9020256451c5ec06ea2ad11722338d3aa2546
Status: Image is up to date for quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-17
quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-17
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on native-image 17.0.8 2023-07-18
OpenJDK Runtime Environment Mandrel-23.0.1.2-Final (build 17.0.8+7)
OpenJDK 64-Bit Server VM Mandrel-23.0.1.2-Final (build 17.0.8+7, mixed mode)

So its version Mandrel-23.0.1.2-Final

When I build it with a locally installed graalVM mandrel-java17-22.3.2.1-Final i have no issues building my app. It just won't start when the app uses version 2.3.0 of quarkus-google-cloud-services-bom.

@loicmathieu
Copy link
Collaborator

There seems to be an issue around GraalVM/Google GAX/Apache arrow, see apache/camel-quarkus#5006

As a workaround, you can create a native-image.properties file in your application like here: quarkiverse/quarkus-micrometer-registry@494ea06

@loicmathieu
Copy link
Collaborator

Google Cloud Services 2.5.0 which will be included in the very soon to be released Quarkus Platform 3.4.0 fixes the issue, I tested it in the reproducer.

@ayhanap
Copy link

ayhanap commented Nov 3, 2023

I still get the same NullPointerException error with 2.6.0 and 2.5.0 (Not the native build error)

So my application and the reproducer posted above builds successfully but when you start the native application, it fails instantly with the following logs..

Nov 03, 2023 5:11:22 AM io.quarkus.runtime.ApplicationLifecycleManager run
ERROR: Failed to start application (with profile [prod])
java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
        at io.quarkus.runtime.Application.start(Application.java:101)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
        at io.quarkus.runner.GeneratedMain.main(Unknown Source)
Caused by: java.lang.NullPointerException
        at io.quarkiverse.googlecloudservices.common.GcpDefaultsConfigSourceFactory.getConfigSources(GcpDefaultsConfigSourceFactory.java:47)
        at io.smallrye.config.ConfigurableConfigSource.getConfigSources(ConfigurableConfigSource.java:50)
        at io.smallrye.config.SmallRyeConfig$ConfigSources.mapLateSources(SmallRyeConfig.java:669)
        at io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(SmallRyeConfig.java:553)
        at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:69)
        at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:629)
        at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
        at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
        ... 7 more

@loicmathieu
Copy link
Collaborator

I can build and start the native image of your reproducer using Quarkus 3.5.0 and Google Cloud Services 2.6.0.
Can you validate that you use both latest version?

@ctschubel
Copy link
Author

I have no more issues building the project that I provided after setting quarkus.platform.version >= 3.4.0 and quarkus.google-cloud-services.version >= 2.5.0 in the pom.xml.

I used mandrel-java17-22.3.2.1-Final to test the build.

@zakkak
Copy link

zakkak commented Nov 8, 2023

@ctschubel great to hear.

Please consult https://github.com/graalvm/mandrel/wiki for which Mandrel version to use with which Quarkus version when not using the default Quarkus builder image.

@ayhanap
Copy link

ayhanap commented Nov 9, 2023

Ok so this works with 3.4.0 or 3.5.0 but not with 3.2.8.Final. What is the related PR or change so I can track if it's going to make into LTS?

@loicmathieu
Copy link
Collaborator

There is no change in this library itself, it's a matter of aligning Google Cloud SDK version with GraalVM version so I doubt it will go into the LTS of Quarkus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants