You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Ravindranath Akila <ra...@gmail.com> on 2010/02/10 16:27:56 UTC

Re: REQUIRES_NEW within a NEVER transaction throwing an exception, bug or misuse?

Hello,
  I am sorry for the belated reply. I am continuing the thread to see if
this is an issue/shortcoming with OpenEJB or Specs itself as now the
transactional hierarchy I use avoids this scenario.

I was using version 3.1.1 AFAIK when encountering the problem but now I am
at 3.1.2. Not sure. Sorry about that.

Always my database operations have been withing stateless beans and never
within a stateful bean.

Actually I seek clarification on OpenEJB side. Is it just that the
specification does not mention if this kind of nesting(flat) is possible, or
is it that the EJB implementations are supposed to decide whether to support
it or not.

Finally, it would be great if we can actually come up with the nesting
scenarios available as which are supported and which not.

IMHO, having a REQUIRES or REQUIRES_NEW within any other transaction type,
should work.

>
>  I have an operation on which
>>
>> one is a dirty read, so the transaction scope is NEVER
>> and the other requires a transaction, hence REQUIRES_NEW.
>>
>> I need to call both these in the same bean so unless I mark this caller
>> method otherwise, it defaults.
>> Therefore I tried marking it NEVER, NOT_SUPPORTED and SUPPORTS but all
>> these
>> throw exceptions.
>>
>> Caller Method = A
>>
>> A => NEVER or NOT_SUPPORTED or SUPPORTS
>>
>> Called Methods = B and C
>>
>> B => NEVER, NOT_SUPPORTED (this is the dirty read)
>> C => REQUIRES_NEW
>>
>> A calls B, then C
>>
>> it seems that using ANY transaction scope, i.e. all enlisted in
>> transactionattribute class I cannot call both the two other methods, one
>> not
>> supporting or rejecting a transaction(B) and the other requiring a new
>> one(C).
>>
>> I agree that nested transactions are not supported in EJB, but if the
>> caller(A) is marked NEVER, NOT_SUPPORTED or SUPPORTS, and was called from
>> an
>> ordinary method(having no transaction scope), then it should not impose
>> any
>> transaction to methods IT calls. It if it does, it should sleep and let
>> them
>> handle it from there. I could not find anything on Google or the Sun
>> tutorial.
>>
>
> Do you know what OpenEJB version you are using?
>
> Also is the bean in question a stateful session bean?  And is there a
> transaction in progress in which the stateful bean is participating when
> method A is called?
>
> I.e. is the stateful bean inside a transaction when you attempt to invoke a
> method on it outside the transaction via a NEVER or NOT_SUPPORTED method?
>
> -David
>
-- 
Sincerely,
  Ravindranath Akila...

Re: REQUIRES_NEW within a NEVER transaction throwing an exception, bug or misuse?

Posted by Ravindranath Akila <ra...@gmail.com>.
Will do but currently not free. I will try to post a sample here as soon as
possible.

On Thu, Feb 11, 2010 at 1:24 PM, David Blevins <da...@visi.com>wrote:

>
> On Feb 10, 2010, at 7:27 AM, Ravindranath Akila wrote:
>
>  Hello,
>>  I am sorry for the belated reply. I am continuing the thread to see if
>> this is an issue/shortcoming with OpenEJB or Specs itself as now the
>> transactional hierarchy I use avoids this scenario.
>>
>> I was using version 3.1.1 AFAIK when encountering the problem but now I am
>> at 3.1.2. Not sure. Sorry about that.
>>
>> Always my database operations have been withing stateless beans and never
>> within a stateful bean.
>>
>> Actually I seek clarification on OpenEJB side. Is it just that the
>> specification does not mention if this kind of nesting(flat) is possible,
>> or
>> is it that the EJB implementations are supposed to decide whether to
>> support
>> it or not.
>>
>> Finally, it would be great if we can actually come up with the nesting
>> scenarios available as which are supported and which not.
>>
>> IMHO, having a REQUIRES or REQUIRES_NEW within any other transaction type,
>> should work.
>>
>
> I can confirm that it is *illegal* for a stateful bean in a transaction to
> leave that transaction and join another transaction. See EJB 3.0 spec Figure
> 5 where it details "method ready in TX".  However we have always supported
> it, with the exception of releases 3.1 and 3.1.1.  In those two releases
> there was an issue that was fixed in 3.1.2.
>
> If you are using stateless beans only, then you shouldn't see an issue with
> one stateless bean calling another stateless bean, regardless of the
> transaction of the calling stateless bean and the transaction settings of
> the target stateless bean.  If this is where you're running into an error,
> if you could create a small sample project that reproduces the issue, we'll
> look into it right away.
>
> -David
>
>


-- 
  Ravindranath Akila...

Re: REQUIRES_NEW within a NEVER transaction throwing an exception, bug or misuse?

Posted by David Blevins <da...@visi.com>.
On Feb 10, 2010, at 7:27 AM, Ravindranath Akila wrote:

> Hello,
>  I am sorry for the belated reply. I am continuing the thread to see  
> if
> this is an issue/shortcoming with OpenEJB or Specs itself as now the
> transactional hierarchy I use avoids this scenario.
>
> I was using version 3.1.1 AFAIK when encountering the problem but  
> now I am
> at 3.1.2. Not sure. Sorry about that.
>
> Always my database operations have been withing stateless beans and  
> never
> within a stateful bean.
>
> Actually I seek clarification on OpenEJB side. Is it just that the
> specification does not mention if this kind of nesting(flat) is  
> possible, or
> is it that the EJB implementations are supposed to decide whether to  
> support
> it or not.
>
> Finally, it would be great if we can actually come up with the nesting
> scenarios available as which are supported and which not.
>
> IMHO, having a REQUIRES or REQUIRES_NEW within any other transaction  
> type,
> should work.

I can confirm that it is *illegal* for a stateful bean in a  
transaction to leave that transaction and join another transaction.  
See EJB 3.0 spec Figure 5 where it details "method ready in TX".   
However we have always supported it, with the exception of releases  
3.1 and 3.1.1.  In those two releases there was an issue that was  
fixed in 3.1.2.

If you are using stateless beans only, then you shouldn't see an issue  
with one stateless bean calling another stateless bean, regardless of  
the transaction of the calling stateless bean and the transaction  
settings of the target stateless bean.  If this is where you're  
running into an error, if you could create a small sample project that  
reproduces the issue, we'll look into it right away.

-David