[
https://issues.jboss.org/browse/WFLY-12535?page=com.atlassian.jira.plugin...
]
Scott Marlow commented on WFLY-12535:
-------------------------------------
From a few years ago,
[
https://github.com/eclipse-ee4j/jpa-api/issues/70] ("Allow two phase bootstrap
approach to creating the EntityManagerFactory") is for deploying persistence units
via two phases, which WildFly does with Hibernate currently (via Hibernate extensions) but
not EclipseLink.
For bean validator, perhaps there could be a workaround that we could do, like detecting
that the bean validator factory is null and creating a new bean validator factory as a
workaround.
For CDI, it is tougher to workaround [WFLY-12535] (other than setting the
jboss.as.jpa.classtransformer to false) as initializing CDI (Weld), requires reading
application classes, which must be done after the JPA persistence provider has enhanced
entity classes.
If EclipseLink implemented [
https://github.com/eclipse-ee4j/jpa-api/issues/70], then
WildFly could expect to run the first (JPA) bootstrap phase very early in deployment (at
which time the EclipseLink class transformer can be registered, so that entity class
transformation works), EclipseLink could then expect to not use the BeanValidator or CDI
BeanManager until the second phase.
If EclipseLink also implemented [
https://github.com/eclipse-ee4j/jpa-api/issues/83], that
would also help with improving CDI integration + JPA listeners, which isn't really
related to [WFLY-12535].
Container does not pass the beanManager when creating eclipselink
EntityManagerFactory
--------------------------------------------------------------------------------------
Key: WFLY-12535
URL:
https://issues.jboss.org/browse/WFLY-12535
Project: WildFly
Issue Type: Bug
Components: JPA / Hibernate
Affects Versions: 16.0.0.Final
Reporter: charles ghislain
Assignee: Scott Marlow
Priority: Major
Attachments: server.log, server.log
When creating the entity manager factory for eclipseliknk using
`javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory`, wildfly
does not pass the properties required by the jee8 spec, as specified in the javadoc of
this method:
{code}
If a Bean Validation provider is present in the classpath, the container must pass the
ValidatorFactory instance in the map with the key
"javax.persistence.validation.factory". If the containing archive is a bean
archive, the container must pass the BeanManager instance in the map with the key
"javax.persistence.bean.manager"
{code}
Debugging the eclipselink implementation of this method,
`org.eclipse.persistence.jpa.PersistenceProvider#createContainerEntityManagerFactory`, the
properties set by the container contains the following 3 entries:
{code:java}
eclipselink.logging.logger -> org.jipijapa.eclipselink.JBossLogger
eclipselink.archive.factory -> org.jipijapa.eclipselink.JBossArchiveFactoryImpl
eclipselink.target-server -> org.jipijapa.eclipselink.WildFlyServerPlatform
{code}
I think this prevents CDI injection in custom ConstraintValidators, as mentionned on an
old eclipselink thread:
https://www.eclipse.org/lists/eclipselink-users/msg08503.html.
I have a `ConstraintValidator` with an `@Inject`ed EJB, but when validation is triggered
on the call to `javax.persistence.EntityManager#merge`, the injected field is null.
The wildfly installation has been updated to include eclipselink as per documentation:
the org.eclipse.persistence module has been updated to include the eclipselink jar with
the following descriptor:
{code:java}
<module xmlns="urn:jboss:module:1.1"
name="org.eclipse.persistence">
<resources>
<!-- jipijapa line is kept from the original module -->
<resource-root path="eclipselink.jar">
<filter>
<exclude path="javax/**" />
</filter>
</resource-root>
</resources>
<dependencies>
<module name="asm.asm"/>
<module name="javax.api"/>
<module name="javax.annotation.api"/>
<module name="javax.enterprise.api"/>
<module name="javax.persistence.api"/>
<module name="javax.transaction.api"/>
<module name="javax.validation.api"/>
<module name="javax.xml.bind.api"/>
<module name="javax.ws.rs.api"/>
<module name="org.antlr"/>
<module name="org.apache.commons.collections"/>
<module name="org.dom4j"/>
<module name="org.jboss.as.jpa.spi"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.vfs"/>
</dependencies>
</module>
{code}
The persistence unit provider has been set to
`org.eclipse.persistence.jpa.PersistenceProvider` in the persistence.xml file.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)