[ 
https://issues.apache.org/jira/browse/TOMEE-4650?focusedWorklogId=1033234&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1033234
 ]

ASF GitHub Bot logged work on TOMEE-4650:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 31/Jul/26 14:34
            Start Date: 31/Jul/26 14:34
    Worklog Time Spent: 10m 
      Work Description: jungm commented on PR #2847:
URL: https://github.com/apache/tomee/pull/2847#issuecomment-5144026339

   Thanks — split done, and you were right on the blocking point.
   
   I reproduced the `AmbiguousResolutionException` before touching anything: 
with the extension in place, `ProducedExtendedEmTest` fails deployment with 
`There is more than one Bean with type jakarta.persistence.EntityManager 
Qualifiers: [@Default]`. That's a regression I should have caught, and it's the 
clearest argument for splitting.
   
   **This PR** is now only the `close()` guard — two lines plus its test. 
`ProducedExtendedEmTest` and `ResourceLocalCdiEmTest` are green again.
   
   **The extension** is preserved on `claude/tomee-4650-jpa-cdi-extension` and 
will return as its own PR. Taking your points: the missing 
`registerDefaultBeanIfMissing`-style `getBeans()` guard, 
`isVisibleInCurrentApp`-style app scoping plus the `webappName` filter and 
qualifier-set dedup, reusing `ConcurrencyCDIExtension`'s 
`annotationEquals`/`annotationHashCode` rather than my one-liners, and its full 
`validateAndCreateQualifiers` including the defaults/`@Nonbinding` checks.
   
   On the smaller items — you're right that 
`jakarta.persistence.qualifiers`/`.scope` aren't spec properties. I took them 
from the Platform spec's "Additional EntityManagerFactory Properties" table in 
`CDI-JPA.adoc`, but that's a platform-spec table, not something the API jar 
defines, and minting `jakarta.*` names was the wrong call regardless; I'll move 
them to `openejb.*`. Also agreed on `JndiConstants`, dropping the unreachable 
`jakarta.transaction` fallback, validating `<scope>`, the dead `SchemaManager` 
wiring, and that `qualifierSelectsTheMatchingPersistenceUnit` is tautological.
   
   On your question about `TransactionScoped` and RESOURCE_LOCAL: the platform 
spec states the `EntityManager` bean's scope is the `<scope>` element "or 
`jakarta.transaction.TransactionScoped` if no scope is explicitly specified", 
with no carve-out for RESOURCE_LOCAL — so unconditional as written. But that 
yields an unusable bean for a RESOURCE_LOCAL unit, which reads like a spec gap 
rather than an intended outcome. I'll consult `unitInfo.transactionType` and 
raise it upstream rather than guess. The unwrapped-EM point stands too — it 
should go through `JtaEntityManager`.




Issue Time Tracking
-------------------

    Worklog Id:     (was: 1033234)
    Time Spent: 0.5h  (was: 20m)

> Undeploy closes an already-closed EntityManagerFactory; PU CDI qualifier 
> beans missing
> --------------------------------------------------------------------------------------
>
>                 Key: TOMEE-4650
>                 URL: https://issues.apache.org/jira/browse/TOMEE-4650
>             Project: TomEE
>          Issue Type: Bug
>            Reporter: Markus Jung
>            Assignee: Markus Jung
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> When a test closes a container-managed {{EntityManagerFactory}} (EMF) itself, 
> TomEE's undeploy path calls {{close()}} on it again. 
> {{Assembler.destroyApplication}} then fails with "Attempting to execute an 
> operation on a closed EntityManagerFactory". The test method itself passes; 
> only the undeploy step after it errors. TomEE must check whether the EMF is 
> already closed before calling {{close()}} on it during undeploy.
> Separately, TomEE does not register the CDI qualifier beans that Jakarta 
> Persistence 3.2 requires for {{persistence.xml}}-declared units. When an app 
> injects {{EntityManagerFactory}}, {{EntityManager}}, or 
> {{PersistenceUnitUtil}} with a qualifier such as {{@CtsEm2Qualifier}}, 
> deployment fails with {{UnsatisfiedResolutionException}}. TomEE is missing 
> this part of the Jakarta Persistence 3.2 CDI integration.
> Both problems show up on Plume (EclipseLink) and on the webprofile 
> distribution (OpenJPA) alike, so neither is a persistence provider defect.
> h2. Steps to reproduce / TCK reference
> * 
> {{ee.jakarta.tck.persistence.core.entityManagerFactoryCloseExceptions.ClientPmservletTest}}
>  and {{ClientPuservletTest}} — excluded in 
> {{runner-webprofile/exclusions/persistence-javatest.txt}} in the 
> apache/tomee-tck harness repo. The {{exceptionsTest}} methods pass; the class 
> reports an undeploy error.
> * {{ee.jakarta.tck.persistence.ee.cdi.ServletEMLookupTest}} — excluded in 
> {{runner-webprofile/exclusions/persistence-servlet.txt}}. Deployment fails 
> with {{UnsatisfiedResolutionException}} for {{@CtsEm2Qualifier}}.
> Remove the matching lines from both exclusion files once fixed.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to