persistence@glassfish.java.net

AW: Transaction flow problem using _at_TransactionAttribute

From: Oleg Mayevskiy <mayevskiy_at_spendino.de>
Date: Fri, 3 Sep 2010 19:19:56 +0200

No, i don't
Should i?

-----Ursprüngliche Nachricht-----
Von: Marina Vatkina [mailto:marina.vatkina_at_oracle.com]
Gesendet: Freitag, 3. September 2010 19:03
An: persistence_at_glassfish.dev.java.net
Betreff: Re: Transaction flow problem using @TransactionAttribute

Do you catch and suppress exception in ejb3 when ejb4.notify fails?

-marina

Oleg Mayevskiy wrote:
>
> Hello.
>
> I have a problem with transaction flow (commitment).
>
> Here is my scenario.
>
> 1) Call ejb method ejb1.notify(…) it has no special
> TransactionAttributeType annotated, so TransactionAttributeType = REQUIRED
>
> 2) Inside of ejb1 I call ejb2.notify(…) this notify method is
> annotated with
> @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW), so new
> transaction is made here
>
> 3) Inside of ejb2 I call then ejb3.notify(…) this again has no special
> TransactionAttributeType annotated, so transaction from ejb2 is used
>
> 4) Inside of ejb3 I call ejb4.notify(…) this is annotated with
> @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW),so new
> transaction should be used, but this transaction failes and rolles back.
>
> 5) What I now would expect is that transaction of ejb2.notify and also
> of ejb3.notify process successfully, but it failes too, because
> ejb4.notify failed, why does it happen? I would expect this behavior
> only if ejb4.notify(…) would have no
> TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
> annotation, but REQUIRED instead.
>
> Mayby I must tell little more about ejb3 class
>
> It is definied like this:
>
> @Stateless
>
> public class Ejb4 extends Ejb3abstractClass implements Ejb4Local {…}
>
> where Ejb3abstractClass is an abstract java class without @Stateless
> annotation
>
> so the implementation of ejb4.notify(…) method is inside the
> Ejb4abstractClass , also the
> @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
> annotation is made here and not directly in Ejb4 class, maybe is this
> the problem? Please tell me if not.
>
> best regards
>
> Oleg Mayevskiy
>