Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Beans.getReference(...) fails with CDI producer class #337
However Beans.getReference seems to have different / broken behaviour wrt producer methods.
SomeClass someObjectA = BeanManager.INSTANCE.getReference(SomeClass .class);
SomeClass someObjectA = Beans.getReference(SomeClass .class);
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001305: The given type class SomeClassProducer is not a type of the bean Producer Method [SomeClass] with qualifiers [@Any @default] declared as [[BackedAnnotatedMethod] @Produces @RequestScoped public SomeClassProducer.createSomeClass ()]
The cause of this problem is the following Code in BeansLocal:
As documented getBeanClass returns the "managed bean or session bean or of the bean that declares the producer method or field."
Is this intended? Passing the intended class instead of bean.getBeanClass() would yield the desired result.
We are using Websphere Liberty (WebSphere Application Server 188.8.131.52) using Weld 2.4.
Thank you for your report. This is certainly not the intent. The fix is available as per today's 2.6-SNAPSHOT. Can you please give it a try and let me know?
The more clean way, however, is to directly use CDI's own utility class.
This only doesn't work in very specific circumstances and this is where only