Do you really want the Hibernate session? Keep in mind that it is
managed by the EE container and will be closed when the transaction
completes or the component invocation ends.
You can also call
entityManagerFactory.unwrap(org.hibernate.SessionFactory.class) to get
the session factory or entityManager.unwrap(org.hibernate.session.class
to get the session.
On 01/22/2015 08:35 AM, Robert Marcano wrote:
I have noticed that all *InjectionServices javadoc say that those
implementations should do the required injection point validations. for
"Register a persistence context injection point. The implementation
validates the injection point ..."
But for some reason if a JpaInjectionServices implementation is
registered, an internal validation is triggered
"WELD-001517: The type of the resource producer field
[[BackedAnnotatedField] @PersistenceContext private
com.example.TestBean.session] does not match the resource type interface
javax.persistence.EntityManager" See 
This field class is an Hibernate session, Wildfly support injecting that
using @PersistentContext , but this validations is blocking me to do
the same in a mock test environment I am coding. I am not sure how
Wildfly inject it with Weld or if they skip Weld injecting JPA instances
because of this. Why this validation is harcoded on Weld, when for
example EjbInjectionServices doesn't force any predefined validation?
Shouldn't it be removed and leave that validation to the
JpaInjectionServices implementation as the javadoc say it is its
weld-dev mailing list