• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CMT transaction problem

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the other project called the setRollbackOnly() now it's clear to me.

Thank you for your advice!
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic