Transaction flow problem using @TransactionAttribute

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Transaction flow problem using @TransactionAttribute

Oleg Mayevskiy

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

 

Reply | Threaded
Open this post in threaded view
|

Re: Transaction flow problem using @TransactionAttribute

Marina Vatkina-2
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
>
Reply | Threaded
Open this post in threaded view
|

AW: Transaction flow problem using @TransactionAttribute

Oleg Mayevskiy
No, i don't
Should i?

-----Ursprüngliche Nachricht-----
Von: Marina Vatkina [mailto:[hidden email]]
Gesendet: Freitag, 3. September 2010 19:03
An: [hidden email]
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
>

Reply | Threaded
Open this post in threaded view
|

Re: AW: Transaction flow problem using @TransactionAttribute

Marina Vatkina-2
If you don't, a RuntimeException causes a domino effect in transaction
failures up the stack. Check EJB spec for the details of exception handling.

Best,
-marina

Oleg Mayevskiy wrote:

> No, i don't
> Should i?
>
> -----Ursprüngliche Nachricht-----
> Von: Marina Vatkina [mailto:[hidden email]]
> Gesendet: Freitag, 3. September 2010 19:03
> An: [hidden email]
> 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
>>
>>    
>
>  
Reply | Threaded
Open this post in threaded view
|

AW: AW: Transaction flow problem using @TransactionAttribute

Oleg Mayevskiy
Ok so my error was not capture the ejb runtime exception.

Thank you very much

O.

-----Ursprüngliche Nachricht-----
Von: Marina Vatkina [mailto:[hidden email]]
Gesendet: Freitag, 3. September 2010 19:33
An: [hidden email]
Betreff: Re: AW: Transaction flow problem using @TransactionAttribute

If you don't, a RuntimeException causes a domino effect in transaction
failures up the stack. Check EJB spec for the details of exception handling.

Best,
-marina

Oleg Mayevskiy wrote:

> No, i don't
> Should i?
>
> -----Ursprüngliche Nachricht-----
> Von: Marina Vatkina [mailto:[hidden email]]
> Gesendet: Freitag, 3. September 2010 19:03
> An: [hidden email]
> 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
>>
>>    
>
>