File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question for CMT Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question for CMT Session Bean" Watch "Question for CMT Session Bean" New topic
Author

Question for CMT Session Bean

Jason Hunt
Ranch Hand

Joined: Sep 09, 2002
Posts: 51
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


SCJP, SCWCD, SCBCD, SCDJWS, OCA9i,<br />IBM Certified WAS5.0 Admin<br />IBM Certified Solution Developer - WebSphere Studio 5.0<br />IBM Certified Solution Developer - XML and related Technologies
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
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

Joined: Sep 09, 2002
Posts: 51
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question for CMT Session Bean