-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Unable to inject custom qualified beans when creating them using SyntheticBeanBuildItem - Tests in deployment module are ok not in integration-tests module #45289
Comments
So the error message actually gives you a good hint:
It looks for a bean with only the What you're missing is that you need to add the qualifier as a bean. I'm not entirely sure why it works in
Actually, given it's very simple, here is a diff: diff --git a/deployment/src/main/java/org/acme/qualifier/synthetic/bean/extension/deployment/QualifierSyntheticBeanExtensionProcessor.java b/deployment/src/main/java/org/acme/qualifier/synthetic/bean/extension/deployment/QualifierSyntheticBeanExtensionProcessor.java
index 19678f9..3e189c9 100644
--- a/deployment/src/main/java/org/acme/qualifier/synthetic/bean/extension/deployment/QualifierSyntheticBeanExtensionProcessor.java
+++ b/deployment/src/main/java/org/acme/qualifier/synthetic/bean/extension/deployment/QualifierSyntheticBeanExtensionProcessor.java
@@ -1,6 +1,8 @@
package org.acme.qualifier.synthetic.bean.extension.deployment;
+import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
+import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
@@ -32,7 +34,11 @@ class QualifierSyntheticBeanExtensionProcessor {
@Record(ExecutionTime.RUNTIME_INIT)
List<SyntheticBeanBuildItem> registerPersons(
final ApplicationIndexBuildItem applicationIndexBuildItem,
- final HelloWorldServiceRecorder helloWorldServiceRecorder) {
+ final HelloWorldServiceRecorder helloWorldServiceRecorder,
+ BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
+ // add the qualifier as a bean
+ additionalBeans.produce(new AdditionalBeanBuildItem(Person.class));
+
final Set<String> persons = applicationIndexBuildItem.getIndex()
.getAnnotations(DotName.createSimple(Person.class))
.stream() |
@gsmet Thanks it works. |
I think the issue here is that the resulting archive created from
My assumption would be the same although I didn't dig deeper. |
Closing the issue as answered. |
Describe the bug
I would like to create beans following the value of a Qualifier
The objective is to pass the value of this qualifier inside the bean and reuse it. Each qualifier will create is own bean.
Following this reproducer https://github.com/dcdh/qualifier-synthetic-bean
I would like to say hello
name
where name is peak up from thePerson
Qualifier.Tests inside deployment module are working fines. However it is not the case in the
integration-tests
module.To produce these beans I use this custom buildStep:
Expected behavior
In
integration-tests
module endpoints should returnedHello Martin
andHello Guillaume
.Actual behavior
It fails to inject both beans. It seems that Arc is not able to find HelloWorldServices qualified with Person having Martin and Guillaume in name.
How to Reproduce?
Output of
uname -a
orver
Linux fedora-2.home 6.11.6-300.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 16:16:00 UTC 2024 x86_64 GNU/Linux
Output of
java -version
openjdk version "21.0.5" 2024-10-15 OpenJDK Runtime Environment (Red_Hat-21.0.5.0.11-1) (build 21.0.5+11) OpenJDK 64-Bit Server VM (Red_Hat-21.0.5.0.11-1) (build 21.0.5+11, mixed mode, sharing)
Quarkus version or git rev
3.17.5
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.6 (Red Hat 3.9.6-7) Maven home: /usr/share/maven Java version: 21.0.5, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-21-openjdk-21.0.5.0.11-1.fc41.x86_64 Default locale: fr_FR, platform encoding: UTF-8 OS name: "linux", version: "6.11.6-300.fc41.x86_64", arch: "amd64", family: "unix"
Additional information
No response
The text was updated successfully, but these errors were encountered: