[ 
https://issues.apache.org/jira/browse/OPENJPA-3102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152407#comment-18152407
 ] 

Richard Zowalla commented on OPENJPA-3102:
------------------------------------------

Pull request: 
[https://github.com/apache/openjpa/pull/328|https://github.com/apache/openjpa/pull/328]



> Use the BeanManager passed in jakarta.persistence.bean.manager for CDI entity 
> listeners
> ---------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-3102
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-3102
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>             Fix For: 4.3.0
>
>
> The CDI support for entity listeners from OPENJPA-3089 looks up the 
> BeanManager through JNDI ({{java:comp/BeanManager}}, 
> {{java:comp/env/BeanManager}}) and then {{CDI.current()}} 
> ({{EntityListenerCDIFactory}}). It does not use the BeanManager the container 
> passes in the property {{jakarta.persistence.bean.manager}}.
> The spec defines that property as the source of the BeanManager: sections 
> 3.6.1 (entity listeners) and 3.9 (attribute converters) both start with 
> "Obtain a BeanManager instance. (See Section 9.1)", and 9.1 says: "The 
> container is responsible for passing this BeanManager instance via the map 
> that is passed as an argument to the createContainerEntityManagerFactory 
> call. The map key used must be the standard property name 
> jakarta.persistence.bean.manager." The javadoc of 
> {{PersistenceProvider.createContainerEntityManagerFactory}} says the same.
> TomEE passes it ({{EntityManagerFactoryCallable}}) as a lazy proxy, because 
> the EMF is often created before CDI is started for the application. Without 
> the property the lookup can happen before CDI is available, or find the 
> BeanManager of another context, and injection is then silently off.
> Use the BeanManager from {{jakarta.persistence.bean.manager}} when it is set, 
> and only fall back to JNDI and {{CDI.current()}} otherwise. OPENJPA-3101 
> (attribute converters) reuses this setup.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to