Well, I don't think this is that simple. CDI 1.2 spec chapter 6.6.5 says:

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

and

"If a producer field declares a passivating scope and doesn’t only contain
Serializable values at runtime then the container must throw an
IllegalProductException."

Especially "producer field" stresses "Serializable values", not types. And
if my producer returns Hibernate SessionImpl, why would you say that it is
not "Serializable type"? 

"only return Serializable types at runtime" - this says to check the return
value, not the method signature.

As a final point: check chapter 3.5.2. It contains this example:

 @Produces @ConversationScoped @UserDatabase
    public EntityManager create(EntityManagerFactory emf) {
        return emf.createEntityManager();
    }

It seems this is not possible with OpenWebBeans at all. 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.

Donatas



--
View this message in context: 
http://tomee-openejb.979440.n4.nabble.com/IllegalProductException-return-type-must-be-Serializable-for-Hibernate-SessionImpl-tp4681517p4681520.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Reply via email to