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

Config Error with Quarkus 2.0 #18672

Closed
oo00spy00oo opened this issue Jul 14, 2021 · 6 comments
Closed

Config Error with Quarkus 2.0 #18672

oo00spy00oo opened this issue Jul 14, 2021 · 6 comments
Assignees
Labels
area/config triage/invalid This doesn't seem right

Comments

@oo00spy00oo
Copy link

oo00spy00oo commented Jul 14, 2021

Describe the bug

In Migration Guide 2.0, I found:
Mapping of YAML Configuration to complex objects has been removed from io.quarkus.arc.config.ConfigProperties. Please use io.smallrye.config.ConfigMapping instead which is a safer alternative.

But I have an issue bellow, and I must revert to io.quarkus.arc.config.ConfigProperties to solve the issue.

        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:104)
        at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:60)
        at io.smallrye.config.ConfigMappingClass.<init>(ConfigMappingClass.java:35)
        at io.smallrye.config.ConfigMappingClass.createConfigurationClass(ConfigMappingClass.java:27)
        at io.smallrye.config.ConfigMappingClass.access$000(ConfigMappingClass.java:7)
        at io.smallrye.config.ConfigMappingClass$1.computeValue(ConfigMappingClass.java:11)
        at io.smallrye.config.ConfigMappingClass$1.computeValue(ConfigMappingClass.java:8)
        at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:226)
        at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:208)
        at java.base/java.lang.ClassValue.get(ClassValue.java:114)
        at io.smallrye.config.ConfigMappingClass.getConfigurationClass(ConfigMappingClass.java:17)
        at io.smallrye.config.ConfigMappingLoader.getConfigMappingClass(ConfigMappingLoader.java:42)
        at io.smallrye.config.ConfigMappingProvider$Builder.addRoot(ConfigMappingProvider.java:888)
        at io.smallrye.config.ConfigMappings.mapConfiguration(ConfigMappings.java:52)
        at io.smallrye.config.ConfigMappings.registerConfigMappings(ConfigMappings.java:36)
        at io.quarkus.arc.runtime.ConfigRecorder.registerConfigMappings(ConfigRecorder.java:50)
        at io.quarkus.deployment.steps.ConfigBuildStep$registerConfigClasses-2116437784.deploy_0(ConfigBuildStep$registerConfigClasses-2116437784.zig:132)
        at io.quarkus.deployment.steps.ConfigBuildStep$registerConfigClasses-2116437784.deploy(ConfigBuildStep$registerConfigClasses-2116437784.zig:40)
        at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:864)
        at io.quarkus.runtime.Application.start(Application.java:101)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:101)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
        at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:48)
        at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:25)
  

Expected behavior

Using io.smallrye.config.ConfigMapping without any problems.

Actual behavior

No response

How to Reproduce?

package <redact>;

import io.quarkus.arc.config.ConfigProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
@ConfigMapping(prefix = "nats")
public class NatsConfig {
    List<String> servers;
}

application.yml:

nats:
  servers:
    - 0.0.0.0:4222

Output of uname -a or ver

Linux

Output of java -version

openjdk version "11.0.9" 2020-10-20 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.0.1.Final

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

Gradle

Additional information

No response

@oo00spy00oo oo00spy00oo added the kind/bug Something isn't working label Jul 14, 2021
@geoand
Copy link
Contributor

geoand commented Jul 14, 2021

@radcortez has this already been fixed?

@radcortez
Copy link
Member

radcortez commented Jul 14, 2021

Looking into the reproducer code, the @ConfigMapping annotation only applies to interfaces, not classes. I'll check if the current case is working with interfaces.

We probably need to add an explicit warning that the annotation only works with interfaces.

@radcortez
Copy link
Member

I confirm that the same code with the expected interface works as expected. I'll add a warning (or a better exception) to prevent the mistake.

@radcortez
Copy link
Member

Implemented in smallrye/smallrye-config#619

@radcortez
Copy link
Member

@oo00spy00oo let us know if replacing the class with the interface works. Please, check the docs here: https://quarkus.io/guides/config-mappings#config-mappings

@radcortez radcortez self-assigned this Jul 14, 2021
@radcortez radcortez added triage/invalid This doesn't seem right and removed kind/bug Something isn't working labels Jul 16, 2021
@oo00spy00oo
Copy link
Author

@oo00spy00oo let us know if replacing the class with the interface works. Please, check the docs here: https://quarkus.io/guides/config-mappings#config-mappings

Thanks @radcortez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants