Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-1176

IllegalProductException when producer returns Hibernate SessionImpl object

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 1.7.2, 1.7.3
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Environment:
      TomEE 7.0.3

      Description

      I'm using TomEE 7.0.3 WebProfile (thus latest OpenWebBeans) with Hibernate 5.2.9. I'm trying to write CDI producer for ViewScoped EntityManager:

      @PersistenceUnit
      private EntityManagerFactory emf;

      @Produces
      @ViewScoped
      private EntityManager createJTAViewScopedEntityManager()

      { return emf.createEntityManager(SynchronizationType.SYNCHRONIZED)); }

      Yet at the injection point I'm getting exception:
      javax.el.ELException: javax.enterprise.inject.IllegalProductException: WebBeans producer : createJTAViewScopedEntityManager return type in the component implementation class : lt.vu.usecases.cdi.JPAResources with passivating scope @javax.faces.view.ViewScoped must be Serializable.

      That contradicts CDI spec. chapter 6.6.5:

      "If a producer method declares a passivating scope and doesn’t only return Serializable types at runtime, then the container must throw an IllegalProductException."

      My example returns object that is instance of Hibernate SessionImpl, that is Serializable type.

      In addition, the example presented in CDI spec. chapter 3.5.2:

      @Produces @ConversationScoped @UserDatabase
      public EntityManager create(EntityManagerFactory emf)

      { return emf.createEntityManager(); }

      This is not possible with OpenWebBeans. I remember CDI 1.1 spec requiring to check method signatures, but 1.2 no longer says anything about method signatures, CDI must check the object that is being returned.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                donatasc Donatas Ciuksys
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: