You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Markus Jung (Jira)" <ji...@apache.org> on 2026/09/25 05:54:00 UTC

[jira] [Updated] (TOMEE-4711) Jakarta Data repositories fail when called from a @Transactional CDI method

     [ https://issues.apache.org/jira/browse/TOMEE-4711?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Markus Jung updated TOMEE-4711:
-------------------------------
    Description: 
{{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.

  was:
{{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:

> 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.


> 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
>            Reporter: Markus Jung
>            Priority: Major
>
> {{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)