NullPointerException when named query with a converter is compiled before CDI BeanManager is available using WildFly

Description

WildFly builds EntityManagerFactory, before CDI BeanManager is available.

While EntityManagerFactory is being built, a named query that uses a converter will result in org.hibernate.metamodel.model.convert.internal.JpaAttributeConverterImpl#toRelationalValue attempting to use CDI BeanManager (before CDI BeanManager is available), which results in the NPE.

After EntityManagerFactory is built, and, later, when CDI BeanManager is available,
org.hibernate.resource.beans.container.spi.ExtendedBeanManager$LifecycleListener#beanManagerInitialized is called. Only after that happens, is it safe for Hibernate to compile the named query that uses a converter.

Environment

None

Status

Assignee

Unassigned

Reporter

Gail Badner

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Priority

Major
Configure