[
https://issues.apache.org/jira/browse/OPENJPA-3102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152406#comment-18152406
]
ASF subversion and git services commented on OPENJPA-3102:
----------------------------------------------------------
Commit 64f30e248e2ab9121824b8f5ab9fece5d05dc8a8 in openjpa's branch
refs/heads/OPENJPA-3102 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=64f30e248 ]
[OPENJPA-3102] Use the BeanManager passed in jakarta.persistence.bean.manager
for CDI entity listeners
> 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)