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

ConfigMapping and CDI error #18524

Closed
rymurr opened this issue Jul 8, 2021 · 7 comments · Fixed by #18533
Closed

ConfigMapping and CDI error #18524

rymurr opened this issue Jul 8, 2021 · 7 comments · Fixed by #18533
Assignees
Labels
area/arc Issue related to ARC (dependency injection) area/config kind/bug Something isn't working
Milestone

Comments

@rymurr
Copy link

rymurr commented Jul 8, 2021

Describe the bug

When switching from the Deprecated io.quarkus.arc.config.ConfigProperties to io.smallrye.config.ConfigMapping as described in the javadoc we get CDI errors

Expected behavior

Expected behaviour is behaviour prior to the change. All beans are injected correctly

Actual behavior

the class

@ConfigMapping(prefix = "foo")
public interface QuarkusConfig extends Config {
}

no longer gets injected in constructors like:

@Inject
public  Foo(@Any Config) {
}

with errors like:

[1] Unsatisfied dependency for type org.projectnessie.services.config.ServerConfig and qualifiers [@Any]
	- java member: org.projectnessie.services.rest.ConfigResource#config
	- declared on CLASS bean [types=[org.projectnessie.api.ConfigApi, org.projectnessie.services.rest.ConfigResource, java.lang.Object], qualifiers=[@Default, @Any], target=org.projectnessie.services.rest.ConfigResource]

To Reproduce

public class Foo {
 @Inject
 public Foo(@Any FooConfig) {
 }
}

public interface FooConfig {
  String foo()
}

@ConfigMapping(prefix = "foo")
public interface QuarkusFooConfig extends FooConfig {
}

or projectnessie/nessie#1563

Environment (please complete the following information):

Output of uname -a or ver

Linux xxx 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

GraalVM version (if different from Java)

Quarkus version or git rev

2.0.0.Final

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

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /home/xxx/.m2/wrapper/dists/apache-maven-3.8.1-bin/2l5mhf2pq2clrde7f7qp1rdt5m/apache-maven-3.8.1
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-77-generic", arch: "amd64", family: "unix"

@rymurr rymurr added the kind/bug Something isn't working label Jul 8, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 8, 2021

/cc @manovotn, @mkouba

@quarkus-bot quarkus-bot bot added the area/arc Issue related to ARC (dependency injection) label Jul 8, 2021
@geoand
Copy link
Contributor

geoand commented Jul 8, 2021

Does it work without the @Any qualifier?

@geoand
Copy link
Contributor

geoand commented Jul 8, 2021

cc @radcortez

@rymurr
Copy link
Author

rymurr commented Jul 8, 2021

Hey @geoand no it doesn't. The original code didn't use @Any and we tried adding @Any based on #18486 without success.

@geoand
Copy link
Contributor

geoand commented Jul 8, 2021

OK thanks for confirming.

I see what's going on, I'll fix it soon

@geoand
Copy link
Contributor

geoand commented Jul 8, 2021

#18533 fixes the issue

gastaldi added a commit that referenced this issue Jul 9, 2021
Allow injection of entire interface hierarchy when using @ConfigMapping
@quarkus-bot quarkus-bot bot added this to the 2.1 - main milestone Jul 9, 2021
@rymurr
Copy link
Author

rymurr commented Jul 9, 2021

Thanks for the fast turnaround @geoand

@gsmet gsmet modified the milestones: 2.1 - main, 2.0.2.Final Jul 12, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/config kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants