I have updated to Hibernate 5.1 while moving from JBoss 6.2 to 7.1 which is based on Wildfly 11. We’re using JPA 2.1 I need the EntityManager that is created to be available in WELD and it appears Hibernate is not putting it there any longer. I have a CDI extension that is observing using
and looking at the types of the bean wrapped by processBean. It could see an EntityManager in Hibernate 4.3, but does not in 5.1.
I know things are getting fired up by virtue of some logging messages:
[org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl] (ServerService Thread Pool -- 98) Found use of deprecated `hibernate.classLoader.application` setting; use `hibernate.classLoaders` instead
I’ve tried to revert to the single phase JPA bootstrap by setting wildfly.jpa.twophasebootstrap to false. I’ve also tried hibernate.delay_cdi_access set to both true and false. Neither has had any affect.
Any suggestions to get the EntityManager bound in CDI?
I think this question is better asked on the Wildfly or JBoss forums since this is not something that’s addressed by the Hibernate ORM framework itself.
Thanks, Vlad. I’ll go post the question on the JBoss forum.
I am curious, though, what is the intent of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.cdiBeanManager? I don’t see that it has a way of getting set to something !null.
One recent change, is for [https://issues.jboss.org/browse/WFLY-2387], WildFly 11+, is delaying Hibernate CDI beanmanager registration, until after CDI event javax.enterprise.inject.spi.AfterDeploymentValidation is triggered for the application deployment.
During the javax.enterprise.inject.spi.AfterDeploymentValidation event, the Hibernate org.hibernate.jpa.event.spi.jpa.ExtendedBeanManager callback is invoked.
I can think of two possibilities, either we removed something in Hibernate ORM 5.1 that previously helped your processBean() to see the EntityManager, Or somehow, the mentioned change to wait until javax.enterprise.inject.spi.AfterDeploymentValidation, to complete the bean manager registration with Hibernate.
One course of action, could be to compare the ORM 5.1 CDI bean manager registration code, with the ORM 4.3 code, to see if we did remove some code that previously helped your processBean extension, to see the ORM entity manager.
Thanks for the feedback, Scott. Do you, by chance, have access to the RedHat support issues? I opened an issue there following Vlad’s suggestion (https://access.redhat.com/support/cases/#/case/02157081). It has a detailed explanation of the use case. The short of it is that this involves Spring’s org.springframework.data.jpa.repository.cdi.JpaRepositoryExtension class used for CDI integration that exposes Spring Data JPA repositories to CDI. They need the EM to use during AfterBeanDiscovery so they can create those repo instances to put into CDI as injectable beans. We then inject those into EJB3’s which are in turn injected into JSF backing beans.
With your input and what I’ve seen with my own debugging, I’m certain that the EM isn’t in CDI at JpaRepositoryExtension.processBean(ProcessBean) time because of the restructuring of the startup. I haven’t had a chance yet to look at source code, but is there a hook point of any kind we could use to stuff the EM into CDI earlier in the process like the Spring code is expecting? I’m heading over to their forums now to see if anyone else has resolved this combo of Hibernate 5.1, Spring Data JPA 2.0.8, and EAP 7.1