[JIRA] (HHH-16096) Passing an ExtendedBeanManager which is notified too late leads to initialization error
by Vedran Prišćan (JIRA)
Vedran Prišćan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63d101b... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOGI2MTk2YjU2... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16096?atlOrigin=eyJpIjoiOGI2MT... ) HHH-16096 ( https://hibernate.atlassian.net/browse/HHH-16096?atlOrigin=eyJpIjoiOGI2MT... ) Passing an ExtendedBeanManager which is notified too late leads to initialization error ( https://hibernate.atlassian.net/browse/HHH-16096?atlOrigin=eyJpIjoiOGI2MT... )
Change By: Vedran Prišćan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63d101b... )
Hibernate cannot be successfully initialized in the following scenario:
* ExtendedBeanManager is used and is notified too late (for example on WildFly)
* custom _UserType_ that also implements _DynamicParameterizedType_ is used for entity column.
For example, _JsonBinaryType_ from _io.hypersistence.hypersistence-utils-hibernate-60_ does not work on WildFly 27 with Hibernate 6. @Vlad Mihalcea
Cause: There is a missing null check for _BeanManager_ in _org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy.NamedBeanImpl.initialize_.
Note: _hibernate.query.startup_check=false_ and _hibernate.delay_cdi_access=true_ do not resolve the issue.
Stack trace when initialization fails:
{code:java}mnc_standalone | Caused by: org.hibernate.resource.beans.container.internal.NotYetReadyException: CDI BeanManager not (yet) ready to use
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy$NamedBeanImpl.initialize(JpaCompliantLifecycleStrategy.java:231)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl$NamedBeanImpl.initialize(CdiBeanContainerExtendedAccessImpl.java:165)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl$NamedBeanImpl.getBeanInstance(CdiBeanContainerExtendedAccessImpl.java:172)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.resource.beans.internal.ManagedBeanRegistryImpl$ContainedBeanManagedBeanAdapter.getBeanInstance(ManagedBeanRegistryImpl.java:155)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.mapping.BasicValue.setExplicitCustomType(BasicValue.java:828)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.cfg.annotations.BasicValueBinder.fillSimpleValue(BasicValueBinder.java:1238)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.cfg.SetBasicValueTypeSecondPass.doSecondPass(SetBasicValueTypeSecondPass.java:26)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1782)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1729)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:300)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1350)
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1421)
mnc_standalone | at org.hibernate.jipijapa-hibernate6@27.0.1.Final//org.jboss.as.jpa.hibernate.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:45)
mnc_standalone | at org.jboss.as.jpa@27.0.1.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:171)
mnc_standalone | ... 10 more
mnc_standalone | Caused by: java.lang.NullPointerException
mnc_standalone | at org.hibernate@6.1.5.Final//org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy$NamedBeanImpl.initialize(JpaCompliantLifecycleStrategy.java:228)
mnc_standalone | ... 23 more{code}
In [HHH-14914|https://hibernate.atlassian.net/browse/HHH-14914] similar issue was resolved for UserTypes that don't implement DynamicParameterizedType by adding a null check in _JpaCompliantLifecycleStrategy.BeanImpl_.
Solution: add a null check for _BeanManager_ in _org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy.NamedBeanImpl.initialize_ and use fallback producer if null, equivalent to [HHH-14914|https://github.com/hibernate/hibernate-orm/commit/9fec060fe2c61...] commit.
( https://hibernate.atlassian.net/browse/HHH-16096#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16096#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:3d33cb1 )
1 year, 7 months