Yes, org.apache.webbeans.component.AbstractProducerBean#checkScopeType enforces the returned type to be serializable.
Tracked at https://issues.apache.org/jira/browse/OWB-1177 Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://blog-rmannibucau.rhcloud.com> | Old Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2017-04-11 10:04 GMT+02:00 DonatasCiuksys <[email protected]>: > 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. >
