question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Qualifier on alternative bean - duplicate element error

See original GitHub issue

Describe the bug

I have a bean with annotations:

@ApplicationScoped @MyQualifier("some-value") public class MyBean { .. }

In the tests I have an alternative bean for it with following annotations:

@ApplicationScoped @MyQualifier("some-value") @Alternative @Priority(5) public class TestMyBean extends MyBean { .. }

When running the tests, an IllegalArgumentException happens with: duplicate element @MyQualifier(“some-value”)

When I remove the qualifier from the alternative it works as expected.

Expected behavior

I would expect that the Qualifier annotation can be defined on the alternative bean as it was prior to Quarkus 2.3 (Likely, the change was introduced with https://github.com/quarkusio/quarkus/pull/19759)

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

openjdk version “11.0.10” 2021-01-19 LTS

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.4.1.Final

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

No response

Additional information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mkoubacommented, Jan 3, 2022

Why should the qualifier from the supertype be ignored? I´d expect that the qualifier on the supertype is still recognized if the qualifier is marked with @inherited.

I mean it should be ignored if the subtype declares an annotation of the same type… as defined by the CDI spec.

1reaction
mkoubacommented, Jan 3, 2022

But it seems that the issue is already resolved with Quarkus 2.5.x

Yes, the IAE comes from the java.util.Set#of() method and it was fixed in https://github.com/quarkusio/quarkus/pull/21232 in 2.4.2.Final.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Choosing from multiple beans in the context - Manning
You can explicitly select a specific bean using the @Qualifier annotation. If none of the beans are primary and you don't use @Qualifier...
Read more >
No unique bean of type is defined: expected single matching ...
There is only one container-managed bean that IS-A declared type of the autowired field; There are more container-managed beans that validate ...
Read more >
Troubleshooting contexts and dependency injection - IBM
Use this task to troubleshoot errors related to Contexts and Dependency Injection (CDI) for the Java Platform, Enterprise Edition (Java EE) ...
Read more >
25.2 Using Alternatives in CDI Applications
The alternatives that you specify in the beans.xml file apply only to classes in the same archive. Use the @Priority annotation to specify...
Read more >
Spring @Primary Annotation - Baeldung
We apply it at the injection point along with @Autowired. In our case, we select the beans at the configuration phase so @Qualifier...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found