This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubt in BMT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Doubt in BMT" Watch "Doubt in BMT" New topic
Author

Doubt in BMT

kumar mahesh
Greenhorn

Joined: Nov 28, 2007
Posts: 16
...
UserTransaction ut = validContext.getUserTransaction();
ut.begin();
......
ut.setRollbackOnly();
.......
ut.commit();


Is it correct to invoke the setRollBackOnly method in a BMT. What will happen when this method is invoked?
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
This works. UserTransaction can invoke setRollbackOnly method. But this method should be of UserTransaction rather than EJBContext.

I tried this, javax.persistence.TransactionRequiredException: EntityManager must be access within a transaction & on the client it said
BMT stateful bean 'Process' did not complete user transaction properly status=STATUS_MARKED_ROLLBACK.

But why did it give such error on the server. Should'nt it have given a better exception like, EJBTransactionRolledbackException .Exception etc


SCJP 1.4, SCWCD 1.4, SCBCD 1.5
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
http://www.coderanch.com/t/157891/java-EJB-SCBCD/certification/When-UserTransaction-setRollbackOnly-UserTransaction-rollback

http://www.coderanch.com/t/162878/java-EJB-SCBCD/certification/rollback-vs-setRollbackOnly
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
ejbContext.setRollbackOnly();

In CMT, this method causes TransactionRequiredException. But it should be transactionRolledBackexception. This error is generated when server tries to commit.

Any Idea?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in BMT
 
Similar Threads
EJB3 is it possible to mix BMT and CMT?
BMT - CMT
a mock question about transcation
if BMT method called in transaction ?
What happend CMT inside BMT ?? (see)