glassfish
  1. glassfish
  2. GLASSFISH-20796

Producing a Persistence Unit returns nul

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: cdi
    • Labels:
      None

      Description

      I've created a sample to show how Persistence Units can be injected in a typesafe manner using CDI. The complete source code of the sample is available at:

      https://github.com/arun-gupta/javaee7-samples/tree/master/jpa/pu-typesafe

      The application has one Persistence Unit and is "produced" as:

          static @Produces @PersistenceContext(unitName = "defaultPU") @DefaultDatabase EntityManager defaultEM;
      

      But when injected in an EJB as:

          @Inject @DefaultDatabase
          EntityManager defaultEM;
      

      the sampleEM returns null. Injecting the PU the traditional way as:

          @PersistenceContext(unitName = "defaultPU")
          EntityManager defaultEM;
      

      seems to work.

      Attached file provides the sample.

        Activity

        Hide
        jjsnyder83 added a comment -

        Appears to be a bug in Weld. See https://issues.jboss.org/browse/WELD-1505.

        Show
        jjsnyder83 added a comment - Appears to be a bug in Weld. See https://issues.jboss.org/browse/WELD-1505 .
        Hide
        jjsnyder83 added a comment -

        Should be fixed by upgrade to Weld 2.2.10.Final.
        Committed with revision 63813.

        Show
        jjsnyder83 added a comment - Should be fixed by upgrade to Weld 2.2.10.Final. Committed with revision 63813.

          People

          • Assignee:
            jjsnyder83
            Reporter:
            arungupta
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: