[jboss-jira] [JBoss JIRA] (WFLY-12535) Container does not pass the beanManager when creating eclipselink EntityManagerFactory
charles ghislain (Jira)
issues at jboss.org
Wed Sep 11 05:56:00 EDT 2019
charles ghislain created WFLY-12535:
---------------------------------------
Summary: 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
Affects Versions: 16.0.0.Final
Reporter: charles ghislain
Assignee: Brian Stansberry
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.5#713005)
More information about the jboss-jira
mailing list