This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question for CMT Session Bean

 
Jason Hunt
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In spec (P78):
--------------------------------------------------------------------------
An error occurs if a client attempts to invoke a method on the session object and the deployment descriptor for the method requires that the container invoke the method in a different transaction context than the one with which the instance is currently associated or in an unspecified transaction context.
---------------------------------------------------------------------------

I just don't understand how can this happen?

From the spec, this is talking about CMT session bean and container serialize the request to the bean, so that means a method can not be invoked by the client in the middle of another method, if one method finish, the related transaction will be commit or rollback(tx cannot span multiple methods for CMT), new method may create a new transaction(if it needs tx) and starts its own life cycle ..., so from my point of view, each method call from the client is an independent cycle, I can't understand what scenario the above spec is talking about

Any Suggestion is appreciated
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2 situations:

1. client calls with its own txn

The called SFSB CMT method is 'Required' and inherited the client's tx and hence the method will not commit at end of method call.

And, now the client calls the same SFSB but another 'RequiresNew' method. A new txn context has to be created. Which is not allowed.

2. called bean methods call another bean method

If the "another bean method" is marked as "RequiresNew", a new txn context also has to be created but is illegal for sfsb.
 
Jason Hunt
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Alec:

your first situation answer my question, but for your second situation, it is legal situation. because if the method call other method with RequiresNew attribute, then the original transaction will be suspended, so at the same time, there won't be two tx at a time.

thanks again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic