Skip to content

Quarkus fails to resolve quarkus.application.version in dev mode #46718

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

Closed
slinstaedt-hlag opened this issue Mar 11, 2025 · 9 comments · Fixed by #47176
Closed

Quarkus fails to resolve quarkus.application.version in dev mode #46718

slinstaedt-hlag opened this issue Mar 11, 2025 · 9 comments · Fixed by #47176
Labels
area/config area/devmode kind/bug Something isn't working triage/needs-reproducer We are waiting for a reproducer.
Milestone

Comments

@slinstaedt-hlag
Copy link

Describe the bug

When updating quarkus from 3.18.4 to 3.19.2 quarkus applications could not be started in dev mode via it's static main method, if the application's version is being referenced somewhere in it's configuration, e.g. via

quarkus:
  container-image:
    labels:
      app-version: ${quarkus.application.version}

As both are build-time configurations, this should not be an issue with referencing runtime-time config from build-time config.

Note: Starting the application via mvn quarkus:dev works as expected.

Expected behavior

Should start in dev mode as it was for the 3.18.x branch.

Actual behavior

Applications fails to start in dev mode due to either provided or resolved quarkus.application.version:

Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at io.quarkus.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:58)
	at io.quarkus.runtime.Quarkus.launchFromIDE(Quarkus.java:114)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:92)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:48)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:137)
	at com.example.App.main(App.java:8)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at io.quarkus.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:56)
	... 5 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.bootstrap.prebuild.CodeGenException: Failed to initialize application configuration
	at io.quarkus.bootstrap.IDELauncherImpl.launch(IDELauncherImpl.java:97)
	... 10 more
Caused by: java.lang.RuntimeException: io.quarkus.bootstrap.prebuild.CodeGenException: Failed to initialize application configuration
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:458)
	at io.quarkus.deployment.dev.IDEDevModeMain.accept(IDEDevModeMain.java:71)
	at io.quarkus.deployment.dev.IDEDevModeMain.accept(IDEDevModeMain.java:28)
	at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
	at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
	at io.quarkus.bootstrap.IDELauncherImpl.launch(IDELauncherImpl.java:93)
	... 10 more
	Suppressed: java.lang.IllegalStateException: Hot deployment of the application is not supported when updating the Quarkus version. The application needs to be stopped and dev mode started up again
		at io.quarkus.deployment.dev.IsolatedDevModeMain.close(IsolatedDevModeMain.java:334)
		at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:460)
		... 15 more
Caused by: io.quarkus.bootstrap.prebuild.CodeGenException: Failed to initialize application configuration
	at io.quarkus.deployment.CodeGenerator.readConfig(CodeGenerator.java:356)
	at io.quarkus.deployment.CodeGenerator.getConfig(CodeGenerator.java:290)
	at io.quarkus.deployment.dev.CodeGenWatcher.<init>(CodeGenWatcher.java:41)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:419)
	... 15 more
Caused by: io.smallrye.config.ConfigValidationException: Configuration validation failed:
	java.util.NoSuchElementException: SRCFG00011: Could not expand value quarkus.application.version in property quarkus.container-image.labels.app-version
	at io.smallrye.config.SmallRyeConfig.buildMappings(SmallRyeConfig.java:141)
	at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:95)
	at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:773)
	at io.quarkus.deployment.configuration.BuildTimeConfigurationReader.initConfiguration(BuildTimeConfigurationReader.java:412)
	at io.quarkus.deployment.CodeGenerator.lambda$getConfig$6(CodeGenerator.java:291)
	at io.quarkus.deployment.CodeGenerator.readConfig(CodeGenerator.java:354)
	... 18 more

How to Reproduce?

No response

Output of uname -a or ver

Linux NHH43414 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "17.0.14" 2025-01-21

Quarkus version or git rev

3.19.2

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

Apache Maven 3.8.7

Additional information

No response

@slinstaedt-hlag slinstaedt-hlag added the kind/bug Something isn't working label Mar 11, 2025
@slinstaedt-hlag slinstaedt-hlag changed the title Quarkus fails to provide quarkus.application.version in dev mode Quarkus fails to resolve quarkus.application.version in dev mode Mar 11, 2025
@slinstaedt-hlag slinstaedt-hlag changed the title Quarkus fails to resolve quarkus.application.version in dev mode Quarkus fails to resolve quarkus.application.version in dev mode Mar 11, 2025
@geoand
Copy link
Contributor

geoand commented Mar 11, 2025

cc @radcortez

@mcruzdev
Copy link
Contributor

Hi @slinstaedt-hlag I tried to reproduce this issue here but was not possible, could you send a minimal reproducer?

@geoand geoand added the triage/needs-reproducer We are waiting for a reproducer. label Mar 11, 2025
@slinstaedt-hlag
Copy link
Author

slinstaedt-hlag commented Mar 12, 2025

Good day. I tried with an helloworld quarkus application and that also just works fine as you mentioned.

I am currently debugging both our application and the mentioned helloworld app to figure out, what could cause the different startup behaviour. For now I can just tell, that the helloworld intializes the build config during IsolatedDevModeMain#firstStart, where the LauchMode is actually also set to DEVELOPMENT before.

When debugging our application, the build config is getting initialized, when the CodeGenWatcher is getting created (9 lines before), so the LauchMode is still defaulting to NORMAL, causing the prod profile being active.

I am currently investigating, what is causing this, because it does not seem to be expected IMHO.

@slinstaedt-hlag
Copy link
Author

slinstaedt-hlag commented Mar 12, 2025

Okay, I found the cause. In brief: When an quarkus extension is being present, that does some code generation (e.g. avro), the build config get's initialized, before LauchMode is being set to DEVELOPMENT, causing the PROD profile being activated.

Reproducer attached:

quarkus-issue-46718.tar.gz

Remember: You need to start the reproducer from the App#main method, not via mvn quarkus:dev.

@radcortez
Copy link
Member

@mcruzdev are you looking into it?

@mcruzdev
Copy link
Contributor

mcruzdev commented Mar 18, 2025

Hi @radcortez I would like to continue with this, but I do not have where I need to change. Do you have in mind where to start?

@radcortez
Copy link
Member

From the exception, I suspect that the Code Generator Config is not setting (or propagating) quarkus.application.version, so it cannot be appropriately expanded.

Check around those areas... if you can't spot anything out of the ordinary, let me know, and I'll do it.

@mcruzdev
Copy link
Contributor

Sorry for the delay, @radcortez. I'll give this a try today and tomorrow morning. If I don't notice anything unusual, I'll let you know.

@spr-nates
Copy link

Good day! I tried updating our project to version 3.20.1 and updated all the necessary properties. But I suddenly get an error when building/running the project via ./gradlew clean build:

* What went wrong:
Execution failed for task ':quarkusAppPartsBuild'.
> There was a failure while executing work items
   > A failure occurred while executing io.quarkus.gradle.tasks.worker.BuildWorker
      > Configuration validation failed:
                java.util.NoSuchElementException: SRCFG00011: Could not expand value BUILD_VERSION in property quarkus.container-image.tag

I am setting the env variable ${BUILD_VERSION} to quarkus.container-image.tag for the image build of our project. I am using io.quarkus:quarkus-container-image-docker. Before updating the version to 3.20.1, the project works perfectly fine and I think my issue is related with this one. I was able to replicate it on a newly created project. Can you help me with this issue? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config area/devmode kind/bug Something isn't working triage/needs-reproducer We are waiting for a reproducer.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants