tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Romain Manni-Bucau (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENEJB-2122) New Transaction gets rolled back
Date Mon, 23 Nov 2015 12:05:10 GMT

    [ https://issues.apache.org/jira/browse/OPENEJB-2122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15022005#comment-15022005
] 

Romain Manni-Bucau commented on OPENEJB-2122:
---------------------------------------------

I think you are kind of abused by @RequestScoped and your usage of it maybe. Take only de.gold.ressources.TestRessourceTest#_1_testMyRessource
for instance, you call de.gold.ressources.TestRessourceTest#_1_testMyRessource but the request
is shared for the whole test so they share the same entity manager and de.gold.beans.MyTestBean#persistEntity1
em uses the transaction of the test wrapper (transactionCaller) which means it uses the first
tx of the chain where the EJB uses a new TX as defined. Said otherwise JPA/JTA integration
makes it hard to follow with eclipselinks there but JTA is not to blamed.

> 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: Critical
>
> 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
(v6.3.4#6332)

Mime
View raw message