Affects Version/s: 1.7.2, 1.7.3
Fix Version/s: None
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:
private EntityManagerFactory emf;
private EntityManager createJTAViewScopedEntityManager()
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)
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.