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

No config value of type [java.lang.String] exists for: quarkus.application.name #3008

Closed
jorsol opened this issue Jun 27, 2019 · 7 comments · Fixed by #3281
Closed

No config value of type [java.lang.String] exists for: quarkus.application.name #3008

jorsol opened this issue Jun 27, 2019 · 7 comments · Fixed by #3281
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@jorsol
Copy link
Contributor

jorsol commented Jun 27, 2019

Describe the bug
I have generated a config example file with ./mvnw quarkus:generate-config and check that it has the properties:

#
# The name of the application.
# If not set, defaults to the name of the project.
#
#quarkus.application.name=

#
# The version of the application.
# If not set, defaults to the version of the project
#
#quarkus.application.version=

Expected behavior
These example file reads that if not set, defaults to the name/version of the project.

The defaults of the project is assumed to be from Maven ${project.version} and ${project.artifactId}.

Actual behavior
Trying to inject the value

@ConfigProperty(name = "quarkus.application.name")
String appName;

leads to:

javax.enterprise.inject.spi.DeploymentException: No config value of type [java.lang.String] exists for: quarkus.application.name
	at io.quarkus.arc.runtime.ConfigDeploymentTemplate.validateConfigProperties(ConfigDeploymentTemplate.java:37)
	at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties10.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties10.deploy(Unknown Source)
	at io.quarkus.runner.ApplicationImpl1.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:84)
	at io.quarkus.runtime.Application.run(Application.java:196)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
Exception in thread "main" java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl1.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:84)
	at io.quarkus.runtime.Application.run(Application.java:196)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
Caused by: javax.enterprise.inject.spi.DeploymentException: No config value of type [java.lang.String] exists for: quarkus.application.name
	at io.quarkus.arc.runtime.ConfigDeploymentTemplate.validateConfigProperties(ConfigDeploymentTemplate.java:37)
	at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties10.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties10.deploy(Unknown Source)
	at io.quarkus.runner.ApplicationImpl1.doStart(Unknown Source)
	... 3 more

Environment (please complete the following information):

openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-20190523183340.buildslave.jdk8u-src-tar--b03)
OpenJDK 64-Bit GraalVM CE 19.0.2 (build 25.212-b03-jvmci-19-b04, mixed mode)
@jorsol jorsol added the kind/bug Something isn't working label Jun 27, 2019
@vinchauhan
Copy link

I would like to work on this one - I think the fix will come from

https://github.com/quarkusio/quarkus/blob/master/core/creator/src/main/java/io/quarkus/creator/phase/generateconfig/GenerateConfigPhase.java ( Line 161 onwards)

Do we have a document to describe the core components in Qarkus and how they interact or I will have to understand through code.

@dmlloyd
Copy link
Member

dmlloyd commented Jun 28, 2019

The GenerateConfigPhase is just the documentation step. The error indicates that the application name was not set in the configuration, and that it also (for whatever reason) wasn't defaulted as the documentation says it should be.

The class io.quarkus.deployment.steps.ApplicationInfoBuildStep is responsible for reading the application name configuration and ensuring that it is set. Right now it's using an application-info.properties file to load that information, so there's probably some problem with how that was generated.

This approach isn't a good long term solution; we should be using a general mechanism for dynamically supplying default values for build-time configuration properties between stages.

@vinchauhan
Copy link

@dmlloyd - Thank you for the explanation.

@jorsol
Copy link
Contributor Author

jorsol commented Jun 29, 2019

@dmlloyd I forgot to mention that the error is when I try to inject the property quarkus.application.name in a field.

Looking through ApplicationInfoBuildStep and ApplicationInfoUtil, the file application-info.properties is created with the keys artifactId and version which is weird and appears that these values are not read by the @ConfigProperty injection annotation.

The corresponding #1683 PR reads:

and this configuration is meant to be used by extensions that for some reason need this information

which is disappointing since it could be really nice to have those properties available.

@dmlloyd
Copy link
Member

dmlloyd commented Jun 29, 2019

This is almost certainly due to the way these two properties are handled in this code. Normally we register a ConfigSource which contains all of the default values. This code takes a different path, and as a result, the default values are not visible at rum time. On Monday I can take a look. I think we'll also have to add a section to the doc about how to provide default values for build time config properties - and also make sure that ther is a way to do it of course.

@dmlloyd
Copy link
Member

dmlloyd commented Jul 1, 2019

I think this comes down to the following steps:

  • Define a build item representing a build-time ConfigSource
  • Consume that build item in io.quarkus.deployment.steps.ConfigurationSetup#initializeConfiguration
  • Define a build item for specifying a build-time default value (sort of analogous to io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem but for build time)
  • Also consume that item in the same place as above
  • Update the Mojos to make the Maven/Gradle build properties into a config source, as per Support Maven and Gradle properties as a build-time config source #3012
  • Update the Mojos to specify the default value for quarkus.application.name to be ${project.name} for Maven and (whatever) for Gradle, and the default for quarkus.application.version to be ${project.version} for Maven and (whatever) for Gradle
  • Delete the hacky code to pass the properties in via a secondary file

That should be it; then it should be possible to reference these properties from any normal context.

@dmlloyd dmlloyd self-assigned this Jul 1, 2019
dmlloyd added a commit to dmlloyd/quarkus that referenced this issue Jul 8, 2019
dmlloyd added a commit to dmlloyd/quarkus that referenced this issue Jul 8, 2019
dmlloyd added a commit to dmlloyd/quarkus that referenced this issue Jul 18, 2019
Also fix handling of quarkus.application.*

Fixes quarkusio#3008, groundwork for quarkusio#3233
dmlloyd added a commit to dmlloyd/quarkus that referenced this issue Jul 19, 2019
Also fix handling of quarkus.application.*

Fixes quarkusio#3008, groundwork for quarkusio#3233
@aloubyansky aloubyansky added this to the 0.20.0 milestone Jul 19, 2019
@ahofmeister
Copy link

ahofmeister commented Oct 9, 2019

I have still the same issue with 0.23.2. Am I missing something? Setup looks the same as OP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants