[jboss-jira] [JBoss JIRA] (WFLY-12535) Container does not pass the beanManager when creating eclipselink EntityManagerFactory
Scott Marlow (Jira)
issues at jboss.org
Wed Oct 2 09:31:00 EDT 2019
[ https://issues.jboss.org/browse/WFLY-12535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13792270#comment-13792270 ]
Scott Marlow commented on WFLY-12535:
-------------------------------------
Could you please enable TRACE logging for org.jboss.as.jpa and attach the WildFly console output (or server.log) to this jira. Some instructions for doing that are at [https://docs.wildfly.org/17/Developer_Guide.html#troubleshooting].
I'm curious what [https://github.com/wildfly/wildfly/blob/master/jpa/subsystem/src/main/java/org/jboss/as/jpa/service/PersistenceUnitServiceImpl.java#L363] will show.
Some points of reference for passing the beanManager and ValidationFactory into EclipseLink:
[https://github.com/wildfly/wildfly/blob/master/jpa/subsystem/src/main/java/org/jboss/as/jpa/service/PersistenceUnitServiceImpl.java#L78] has constants for properties that should be passed into EclipseLink.
[https://github.com/wildfly/wildfly/blob/master/jpa/subsystem/src/main/java/org/jboss/as/jpa/service/PersistenceUnitServiceImpl.java#L81] is the Map of properties that should be passed into EclipseLink.
[https://github.com/wildfly/wildfly/blob/master/jpa/subsystem/src/main/java/org/jboss/as/jpa/service/PersistenceUnitServiceImpl.java#L146] is where we should be setting ValidationFactory in the "properties" map.
[https://github.com/wildfly/wildfly/blob/master/jpa/subsystem/src/main/java/org/jboss/as/jpa/service/PersistenceUnitServiceImpl.java#L182] is where we should be passing the CDI bean manager in.
[https://github.com/wildfly/wildfly/blob/master/jpa/subsystem/src/main/java/org/jboss/as/jpa/service/PersistenceUnitServiceImpl.java#L365] is where we actually pass the properties into EclipseLink.
Scott
> 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
>
> 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)
More information about the jboss-jira
mailing list