You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Tom (Jira)" <ji...@apache.org> on 2020/03/19 20:14:00 UTC

[jira] [Updated] (OPENEJB-2122) New Transaction gets rolled back

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

Tom updated OPENEJB-2122:
-------------------------
    Priority: Blocker  (was: Critical)

> New Transaction gets rolled back
> --------------------------------
>
>                 Key: OPENEJB-2122
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-2122
>             Project: OpenEJB
>          Issue Type: Bug
>         Environment: Java 8 update 51 64bit
> Windows 7
>            Reporter: Pascal Knüppel
>            Priority: Blocker
>
> I am currently on a project where I need to rollback only part of my transaction. I tested my code on wildfly and it works perfectly. With openejb though all my transactions are rolled back and I am not able to find a workaround.
> I have a really simple stateless bean which calls 2 methods. One method has attribute transaction required and the second has transaction requires new.
> {code:title=MyTestRessource.java|borderStyle=solid}
> @Stateless
> @Path("test")
> public class MyTestRessource {
>     @Inject
>     private MyTestBean myTestBean;
>     @GET
>     @Path("testMethod")
>     @Transactional(Transactional.TxType.NOT_SUPPORTED)
>     public String simpleTestMethod() {
>         myTestBean.persistAnEntity();
>         myTestBean.doOnFail();
>         return "execution finished";
>     }
> }
> {code}
> {code:title=MyTestBean.java|borderStyle=solid}
> @Stateless
> @Path("test")
> @RequestScoped
> public class MyTestBean {
>     @Inject
>     @Named(EntityManagerProducer.oracleEntityManagerName)
>     private EntityManager oracleEntityManager;
>     @Resource
>     private SessionContext sessionContext;
>     @Transactional(Transactional.TxType.REQUIRED)
>     public void persistAnEntity() {
>         FRX_SECURITYVERSION frx_securityversion = new FRX_SECURITYVERSION(
>                 "SV0111", new Date()
>         );
>         oracleEntityManager.persist(frx_securityversion);
>         sessionContext.setRollbackOnly();
>     }
>     @Transactional(Transactional.TxType.REQUIRES_NEW)
>     public void doOnFail() {
>         FRX_SECURITYVERSION frx_securityversion = new FRX_SECURITYVERSION(
>                 "SV0100", new Date(System.currentTimeMillis() + 1000L * 60 * 60 * 24 * 365 * 999)
>         );
>         oracleEntityManager.persist(frx_securityversion);
>     }
> }
> {code}
> If I execute this code in wildfly I get no problems and the entry from the second method is persisted while the first is rolled back. With openejb both entries are rolled back. Is there anything I am missing?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)