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

Quarkus 3.10.0 now requires a GraalVM installation for quarkusDev when quarkus.native.enabled is set to true #40495

Closed
ThoSap opened this issue May 7, 2024 · 24 comments · Fixed by #40496
Assignees
Labels
area/kubernetes area/native-image kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Milestone

Comments

@ThoSap
Copy link

ThoSap commented May 7, 2024

Describe the bug

When upgrading Quarkus from a previous version to Quarkus 3.10.0, the Quarkus CLI migrates
quarkus.package.type=native
to

quarkus.package.jar.enabled=false
quarkus.native.enabled=true

With this change, the dev server ./gradleq quarkusDev can no longer start if any other OpenJDK distribution instead of GraalVM is installed.

With previous versions this worked, as for local development for example Eclipse Adoptium is sufficient and building and testing in native mode is only done by the CI pipeline.

Expected behavior

The local dev server ./gradleq quarkusDev should work if the following properties are set without GraalVM installed.

quarkus.package.jar.enabled=false
quarkus.native.enabled=true

Actual behavior

image

How to Reproduce?

No response

Output of uname -a or ver

Microsoft Windows [Version 10.0.22631.3447]

Output of java -version

OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)

Quarkus version or git rev

3.10.0

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 8.7

Additional information

implementation 'io.quarkus:quarkus-agroal'
implementation 'io.quarkus:quarkus-arc'
implementation 'io.quarkus:quarkus-awt'
implementation 'io.quarkus:quarkus-cache'
implementation 'io.quarkus:quarkus-config-yaml'
implementation 'io.quarkus:quarkus-jdbc-oracle'
implementation 'io.quarkus:quarkus-jdbc-postgresql'
implementation 'io.quarkus:quarkus-kubernetes'
implementation 'io.quarkus:quarkus-micrometer'
implementation 'io.quarkus:quarkus-micrometer-registry-prometheus'
implementation 'io.quarkus:quarkus-oidc'
implementation 'io.quarkus:quarkus-rest'
implementation 'io.quarkus:quarkus-rest-jackson'
implementation 'io.quarkus:quarkus-scheduler'
implementation 'io.quarkus:quarkus-smallrye-health'
implementation 'io.quarkus:quarkus-smallrye-openapi'
@ThoSap ThoSap added the kind/bug Something isn't working label May 7, 2024
Copy link

quarkus-bot bot commented May 7, 2024

/cc @geoand (kubernetes), @iocanel (kubernetes), @zakkak (native-image)

@ThoSap ThoSap changed the title Quarkus 3.10.0 now requires a GraalVM installation when quarkus.native.enabled is set to true Quarkus 3.10.0 now requires a GraalVM installation for quarkusDev when quarkus.native.enabled is set to true May 7, 2024
@dmlloyd
Copy link
Member

dmlloyd commented May 7, 2024

I think this was indirectly caused by #39295. On reaugment, the dev mode processor forces the JAR type to be mutable-jar. Previously, this overrode the native-build setting, but now that native has its own flag, this no longer happens. It's a simple fix though.

The interim workaround would be to set quarkus.native.enabled=false while working in dev mode.

@dmlloyd dmlloyd self-assigned this May 7, 2024
dmlloyd added a commit to dmlloyd/quarkus that referenced this issue May 7, 2024
@quarkus-bot quarkus-bot bot added this to the 3.11 - main milestone May 10, 2024
@gsmet gsmet modified the milestones: 3.11 - main, 3.10.1 May 10, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 10, 2024
@ThoSap
Copy link
Author

ThoSap commented Jun 25, 2024

Hi @dmlloyd @geoand, the issue still persists in Quarkus 3.10.1+, the PR did not fix the issue in combination with Quarkus AWT.
This issue was not there (also in combination with Quarkus AWT) before Quarkus 3.10.0, for example 3.9.4.

I just tried again with Quarkus 3.11.3 and there I get the following error.
The Exception is thrown here:
https://github.com/quarkusio/quarkus/blob/3.11.3/extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java#L153

image

024-06-25 13:47:17,060 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.awt.deployment.AwtProcessor#setupJava2DClasses threw an exception: java.lang.RuntimeException: Failed to get GraalVM version
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:40)
	at io.quarkus.awt.deployment.AwtProcessor.setupJava2DClasses(AwtProcessor.java:153)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
	at java.base/java.lang.Thread.run(Thread.java:1583)
	at org.jboss.threads.JBossThread.run(JBossThread.java:483)
Caused by: java.lang.RuntimeException: Cannot find the `native-image.cmd` in the GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image`
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunnerError.getGraalVMVersionCommand(NativeImageBuildRunnerError.java:21)
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:29)
	... 11 more

	[error]: Build step io.quarkus.awt.deployment.AwtProcessor#setupAWTInit threw an exception: java.lang.RuntimeException: Failed to get GraalVM version
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:40)
	at io.quarkus.awt.deployment.AwtProcessor.setupAWTInit(AwtProcessor.java:121)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
	at java.base/java.lang.Thread.run(Thread.java:1583)
	at org.jboss.threads.JBossThread.run(JBossThread.java:483)
Caused by: java.lang.RuntimeException: Cannot find the `native-image.cmd` in the GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image`
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunnerError.getGraalVMVersionCommand(NativeImageBuildRunnerError.java:21)
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:29)
	... 11 more

	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:331)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:252)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:58)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:113)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:435)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:56)
	at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
	at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
	at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
	at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.awt.deployment.AwtProcessor#setupJava2DClasses threw an exception: java.lang.RuntimeException: Failed to get GraalVM version
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:40)
	at io.quarkus.awt.deployment.AwtProcessor.setupJava2DClasses(AwtProcessor.java:153)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
	at java.base/java.lang.Thread.run(Thread.java:1583)
	at org.jboss.threads.JBossThread.run(JBossThread.java:483)
Caused by: java.lang.RuntimeException: Cannot find the `native-image.cmd` in the GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image`
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunnerError.getGraalVMVersionCommand(NativeImageBuildRunnerError.java:21)
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:29)
	... 11 more

	[error]: Build step io.quarkus.awt.deployment.AwtProcessor#setupAWTInit threw an exception: java.lang.RuntimeException: Failed to get GraalVM version
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:40)
	at io.quarkus.awt.deployment.AwtProcessor.setupAWTInit(AwtProcessor.java:121)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
	at java.base/java.lang.Thread.run(Thread.java:1583)
	at org.jboss.threads.JBossThread.run(JBossThread.java:483)
Caused by: java.lang.RuntimeException: Cannot find the `native-image.cmd` in the GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image`
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunnerError.getGraalVMVersionCommand(NativeImageBuildRunnerError.java:21)
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:29)
	... 11 more

	at io.quarkus.builder.Execution.run(Execution.java:123)
	at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:160)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:327)
	... 9 more
	Suppressed: java.lang.RuntimeException: Failed to get GraalVM version
		at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:40)
		at io.quarkus.awt.deployment.AwtProcessor.setupAWTInit(AwtProcessor.java:121)
		at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
		at java.base/java.lang.reflect.Method.invoke(Method.java:580)
		at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
		at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
		at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
		at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
		at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
		at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
		at java.base/java.lang.Thread.run(Thread.java:1583)
		at org.jboss.threads.JBossThread.run(JBossThread.java:483)
	Caused by: java.lang.RuntimeException: Cannot find the `native-image.cmd` in the GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image`
		at io.quarkus.deployment.pkg.steps.NativeImageBuildRunnerError.getGraalVMVersionCommand(NativeImageBuildRunnerError.java:21)
		at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:29)
		... 11 more
Caused by: java.lang.RuntimeException: Failed to get GraalVM version
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:40)
	at io.quarkus.awt.deployment.AwtProcessor.setupJava2DClasses(AwtProcessor.java:153)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
	at java.base/java.lang.Thread.run(Thread.java:1583)
	at org.jboss.threads.JBossThread.run(JBossThread.java:483)
Caused by: java.lang.RuntimeException: Cannot find the `native-image.cmd` in the GRAALVM_HOME, JAVA_HOME and System PATH. Install it using `gu install native-image`
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunnerError.getGraalVMVersionCommand(NativeImageBuildRunnerError.java:21)
	at io.quarkus.deployment.pkg.steps.NativeImageBuildRunner.getGraalVMVersion(NativeImageBuildRunner.java:29)
	... 11 more

@geoand
Copy link
Contributor

geoand commented Jun 25, 2024

Can you please attach a sample project that fails as you describe?

Thanks

@ThoSap
Copy link
Author

ThoSap commented Jun 25, 2024

Hello Georgios,

we don't need any sophisticated reproducer,
I just tried to reproduce this by downloading the following code starter
https://code.quarkus.io/?g=io.quarkus&a=awt-graalvm-native-required&b=GRADLE&e=awt&e=rest&extension-search=origin:platform%20rest
and set quarkus.native.enabled=true inside the application.properties,
then start with ./gradlew quarkusDev.

I did not try with Maven, but I guess there we will get the exact same error.

I hope this helps!

@geoand
Copy link
Contributor

geoand commented Jun 26, 2024

Hi,

I tried with both Quarkus 3.11.3 and 3.12.0 with the application generated from the link to code.quarkus.io and both versions worked just fine.

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label Jun 26, 2024
@ThoSap
Copy link
Author

ThoSap commented Jun 26, 2024

@geoand remove your GRAALVM_HOME ENV var on your system, then you will get this error.

@geoand
Copy link
Contributor

geoand commented Jun 26, 2024

I did, still works

@ThoSap
Copy link
Author

ThoSap commented Jun 26, 2024

I just launched a fresh Windows 11 Sandbox, installed Eclipse Temurin 21, set the JAVA_HOME ENV var, and launched the Quarkus 3.12.0 code starter from above.
Did you restart the bash/PowerShell/cmd after removing the GraalVM ENV var from your system?

The same issue appears if I try the Maven code starter.
Maybe it is Windows specific, idk (I have to use Windows, company policy).

Gradle
image

Maven
image

@geoand
Copy link
Contributor

geoand commented Jun 26, 2024

I don't have a Windows machine unfortunately...

@ThoSap
Copy link
Author

ThoSap commented Jun 26, 2024

I will try with a fresh WSL instance, maybe I can reproduce this also in a Linux distro.

@ThoSap
Copy link
Author

ThoSap commented Jun 26, 2024

I can confirm this is Windows-specific.
On a fresh Windows Sandbox instance where I just set up Java and the code starter, I get the errors from the comment above (both Maven and Gradle).

I do not get the error on WSL2 with AlmaLinux 9.3 (Rocky Linux is not available in the Windows Store) and the Maven code starter.
image

@geoand
Copy link
Contributor

geoand commented Jun 26, 2024

Very interesting find!

@geoand geoand removed the triage/needs-feedback We are waiting for feedback. label Jun 26, 2024
@ThoSap
Copy link
Author

ThoSap commented Jun 26, 2024

So both Maven and Gradle with the Quarkus 3.12.0 code starter from above work fine under Linux.
I just tried Gradle to double-check.

image

@ThoSap
Copy link
Author

ThoSap commented Jun 26, 2024

Nevermind, it also does not work under Linux, I just forgot to add quarkus.native.enabled=true for both Maven and Gradle for the Quarkus 3.12.0 AWT and REST code starter 🤦🏽‍♂️🤦🏽‍♂️🤦🏽‍♂️

It is almost the same error, this time the stack trace from the GraalVM build -> container runtime detection.

You must do something different when you try to reproduce this @geoand as I also get the same error under Linux.
In addition to the GRAALVM_HOME ENV var, maybe also try to remove GraalVM from the PATH ENV var and JAVA_HOME.

Gradle
image

Maven
image

@geoand geoand removed the env/windows Impacts Windows machines label Jun 26, 2024
@geoand
Copy link
Contributor

geoand commented Jun 26, 2024

I've never been able to reproduce that, so best if someone else gives it a shot

@ThoSap
Copy link
Author

ThoSap commented Jun 26, 2024

It also does not matter if I add quarkus.package.jar.enabled=true, so I have both properties set to true.

quarkus.package.jar.enabled=true
quarkus.native.enabled=true

https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.10#packaging-configuration-gear-white_check_mark
With the Quarkus CLI 3.10.0+ migration the property quarkus.package.type=native was migrated automatically to:

quarkus.package.jar.enabled=false
quarkus.native.enabled=true

So we have a clear behavior change here regarding the AWT usage.

@zakkak
Copy link
Contributor

zakkak commented Jun 26, 2024

@geoand I was able to reproduce the issue (with 3.12.0) by:

  1. unset GRAALVM_HOME
  2. export JAVA_HOME=~/jvms/jdk-21.0.4+3 (that's Adoptium Temurin)
  3. export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin (in my case sdkman was adding native-image to the PATH)
  4. adding the following to the application properties:
quarkus.native.enabled=true
quarkus.package.jar.enabled=false
quarkus.native.container-build=false

@zakkak zakkak reopened this Jun 26, 2024
@geoand
Copy link
Contributor

geoand commented Jun 27, 2024

Thanks @zakkak, I can now reproduce the problem.

This is actually rather serious...
Essentially anywhere we do @BuildStep(onlyIf = { NativeBuild.class }) is susceptible to this problem...

There are a few solutions I can think of, but none of them are great...

@dmlloyd
Copy link
Member

dmlloyd commented Jun 27, 2024

In ReaugmentTask, there is long-standing code to force the packaging (and disable native), which I would have expected to take effect in this case. But I don't see any equivalent code on the initial augmentation path. I'm not certain how it ever worked originally, assuming that it did. But if it did work before, it seems likely to me that it is another side effect of splitting the native-enabled flag out from packaging type.

@geoand
Copy link
Contributor

geoand commented Jun 28, 2024

it seems likely to me that it is another side effect of splitting the native-enabled flag out from packaging type

Very likely

holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Jul 31, 2024
@ThoSap
Copy link
Author

ThoSap commented Aug 21, 2024

Is this fixed in Quarkus 3.13.X?

@zakkak
Copy link
Contributor

zakkak commented Aug 28, 2024

@ThoSap this should be fixed since 3.11 by #40496

I tried reproducing it on 3.13 with no luck. Are you still seeing the issue?

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label Aug 28, 2024
@geoand
Copy link
Contributor

geoand commented Sep 5, 2024

Let's close for now.

If it's still a problem, please mention it and we can reopen

@geoand geoand closed this as completed Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes area/native-image kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants