Search code examples
javatransactionswebspherecontainers

Catching TransactionRolledbackLocalException in Java


I receive javax.ejb.TransactionRolledbackLocalException in Websphere 7 from the container and I wonder how is it possible to catch this exception? I have a timeout set in Websphere and get this message after this time. I run session beans.

I am trying to find what SQl statement was the cause of this exception. Where can i find that?


Solution

  • As per Sun's docs Here's the bottom line guideline: If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception.

    TransactionRolledbackLocalException is an unchecked exception and there is nothing you can do if it happens. You could catch it as Aaron Digulla suggests in his answer, but what is the point ?

    If you catch it then you will be messing with the internals of the App Server. You will get an exception on the client and you can call getCause() on the exception you get on the client to properly notify the user.

    You have two solutions

    1. Look at what is causing the timeout (Probably bad SQL)
    2. Increase the timeout