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

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

                Author: ASF GitHub Bot
            Created on: 25/Sep/26 05:55
            Start Date: 25/Sep/26 05:55
    Worklog Time Spent: 10m 
      Work Description: jungm opened a new pull request, #2950:
URL: https://github.com/apache/tomee/pull/2950

   Fixes [TOMEE-4711](https://issues.apache.org/jira/browse/TOMEE-4711): every 
Jakarta Data repository call from a `@Transactional` CDI method fails with 
`IllegalStateException: Can't use UserTransaction from @Transactional call`.
   
   `RepositoryInvocationHandler.executeInTransaction` used `UserTransaction` to 
check for and start a transaction. [Jakarta Transactions 2.0 
ยง3.7](https://jakarta.ee/specifications/transactions/2.0/jakarta-transactions-spec-2.0#transactional-annotation)
 requires any `UserTransaction` call inside `@Transactional` (other than 
`NOT_SUPPORTED`/`NEVER`) to throw, so the handler now uses the container 
`TransactionManager`. It also only begins its own transaction when there is 
none, rather than whenever the status isn't `ACTIVE`, so a transaction marked 
for rollback is joined instead of hitting a nested `begin()`.
   
   New `JakartaDataTransactionalTest` calls `insert`, `findById`, `save` on a 
loaded entity, and `deleteById` from `@Transactional` methods. All three tests 
fail without the fix and pass with it; the existing data tests and the module's 
unit tests still pass.




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

            Worklog Id:     (was: 1043847)
    Remaining Estimate: 0h
            Time Spent: 10m

> Jakarta Data repositories fail when called from a @Transactional CDI method
> ---------------------------------------------------------------------------
>
>                 Key: TOMEE-4711
>                 URL: https://issues.apache.org/jira/browse/TOMEE-4711
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 11.0.0-M1
>            Reporter: Markus Jung
>            Priority: Major
>             Fix For: 11.0.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {{RepositoryInvocationHandler.executeInTransaction}} looks up 
> {{java:comp/UserTransaction}} and calls {{getStatus()}} on every repository 
> invocation to decide whether to start a transaction.
> Jakarta Transactions 2.0, section 3.7 "Transactional Annotation" 
> (https://jakarta.ee/specifications/transactions/2.0/jakarta-transactions-spec-2.0#transactional-annotation),
>  also in the {{@Transactional}} Javadoc:
> bq. If an attempt is made to call any method of the {{UserTransaction}} 
> interface from within the scope of a bean or method annotated with 
> {{@Transactional}} and a {{Transactional.TxType}} other than 
> {{NOT_SUPPORTED}} or {{NEVER}}, an {{IllegalStateException}} must be thrown.
> TomEE's interceptor enforces that, so any repository call from such a method 
> fails with:
> {code}java.lang.IllegalStateException: Can't use UserTransaction from 
> @Transactional call
> {code}
> The handler should use the container {{TransactionManager}} instead, which is 
> not subject to that restriction.



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

Reply via email to