[GLASSFISH-18046] @Inject @New Instance<SomeClass> not working, getting WELD-001308 Unable to resolve any beans for Types Created: 19/Dec/11  Updated: 21/Mar/13  Resolved: 21/Mar/13

Status: Closed
Project: glassfish
Component/s: cdi
Affects Version/s: 3.1.1_b12
Fix Version/s: 4.0

Type: Bug Priority: Major
Reporter: chrikru Assignee: jjsnyder83
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Windows 7 64-Bit

Tags: 3_1_2-exclude, weld-int-required


see also similar issue for JBoss7: https://issues.jboss.org/browse/WELD-975

According to spec: "...the @New qualifier may be used, allowing the application to obtain a @New qualified bean, as defined in Section 3.12, @New qualified beans" (CDI 1.0; chapter 5.6. Programmatic lookup).

However using programmatic lookup with @New qualifier like:

@Inject @New Instance<Foo> foo;

results in:

org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308 Unable to resolve any beans for Types: [class org.jboss.cditck.arquillian.instance.Foo]; Bindings: [@javax.enterprise.inject.New(value=org.jboss.cditck.arquillian.instance.Foo.class)]

after trying to obtain reference via get() method.

Following code works ok:

@Inject @New Foo foo;

Spec gives following valid example:

@Inject @New(ChequePaymentProcessor.class) Instance<PaymentProcessor> chequePaymentProcessor;

Comment by Sivakumar Thyagarajan [ 04/Jan/12 ]

Could you please submit a reproducible test case? I tried to reproduce this scenario in a developer test
(see http://java.net/projects/glassfish/sources/svn/revision/51888) and couldn't against GlassFish trunk.

At first glance, this appears to be a WELD issue, and hence I will track the resolution of WELD-795 for this.

Comment by chrikru [ 05/Jan/12 ]

I ran the test case locally and it worked fine for me to. So I tried to reproduce my error and succeeded. After some more analysis of the problem, I found something interesting:
If you comment lines 61-63 and lines 91-92 in NewQualifierTestServlet (revision 51900), the test fails. If you remove the comments in lines 61-63 again, it works fine.

It seems, that if the bean, which is used via "@Inject @New Instance<Bean>", was injected before via "@Inject @New Bean", the case with "Instance" is working. Otherwise it fails.

Comment by Sivakumar Thyagarajan [ 10/Dec/12 ]

Transferring to JJ Snyder

Comment by tlcksnyder [ 21/Mar/13 ]

Fixed in Weld as of 1.1.9.Final, 1.2.0.Beta1, 2.0.0.Alpha3.

Generated at Sat Aug 01 22:20:19 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.