Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

CMT transaction problem  RSS feed

 
Stephan Staeheli
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have a CMT problem and I don't have an idea to solve it:

My method in stateless SB BeanA runs with transaction attribute 'RequiresNew' and calls an internal SLSB (with the same trx attribute). Now this one calls another SLSB (let's call it BeanB) from another project. They have an attribute 'Required'.

Now when the call to BeanB crashes and returns me an exception I analyse this exception. When it's exception ExceptionABC then this whould be ok, I don't have to roll back my transaction. Unfortunatly now the whole transaction is marked 'rollback' and I can't change it (or can I?). I can't change my internal SLSB to 'NotSupported' because when I have an internal problem I want to roll back the transaction in the external project, too.

Do I have to another possibilty to handle this? Can I switch back the 'rollback state' in my transaction?

I hope there is a possible solution to solve my problem.

Greets,
Stephan
 
Balazs Borbely
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The think the problem is that the 'ExceptionABC' (named by you) is a RuntimeException and so, according with the EJB spec, the container rolls back the transaction.

Use instead a checked exception.

And also, make sure that the transaction is not marked as setRolbackOnly() in the ejb's source code, make it setRolbackOnly only when your business logic requires it.
 
Stephan Staeheli
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the ExceptionABC is not a RuntimeException, it's just a simple CheckedException. But I don't know if the other project calls setRollbackOnly, I will check that.

So what you say is that when the Exception is not a RuntimeException and nobody calls setRollbackOnly, it should work?

Regards,
Stephan
 
Balazs Borbely
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stephan Staeheli:

So what you say is that when the Exception is not a RuntimeException and nobody calls setRollbackOnly, it should work?

Regards,
Stephan


Yeah, it should work.
 
Stephan Staeheli
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the other project called the setRollbackOnly() now it's clear to me.

Thank you for your advice!
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is there a problem? Bean A and bean B are running in separate transactions, and you are in control of your transaction for bean A.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!