glassfish
  1. glassfish
  2. GLASSFISH-18046

@Inject @New Instance<SomeClass> not working, getting WELD-001308 Unable to resolve any beans for Types

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.1_b12
    • Fix Version/s: 4.0
    • Component/s: cdi
    • Labels:
      None
    • Environment:

      Windows 7 64-Bit

      Description

      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;
      

        Activity

        Hide
        tlcksnyder added a comment -

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

        Show
        tlcksnyder added a comment - Fixed in Weld as of 1.1.9.Final, 1.2.0.Beta1, 2.0.0.Alpha3.
        Hide
        Sivakumar Thyagarajan added a comment -

        Transferring to JJ Snyder

        Show
        Sivakumar Thyagarajan added a comment - Transferring to JJ Snyder
        Hide
        chrikru added a comment -

        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.

        Show
        chrikru added a comment - 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.
        Hide
        Sivakumar Thyagarajan added a comment -

        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.

        Show
        Sivakumar Thyagarajan added a comment - 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.

          People

          • Assignee:
            jjsnyder83
            Reporter:
            chrikru
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: