4 Replies Latest reply on Apr 2, 2002 3:06 AM by bartmann_d

    Transactions and exceptions

    onkalich

      Hi there,

      I have couple of BMP entity beans with one stateless session as facade.
      I used transactions to assemble actions.

      When I throw application exceptions (which have to extends RuntimeException or RemoteException for the transaction), the client must browse down the RemoteException to find the application exception.

      Can the client receive the application exception instead of the RemoteException?

        • 1. Re: Transactions and exceptions
          bartman

          I think the answer to this question has to be no -- you have to extract the wrapped exception from the remote exception even if the exception thrown extends RemoteException. It's a little annoying but not the end of the world. Don't assume that this is the gospel truth by any means: it's just what I've observed in my experience.

          Bart

          • 2. Re: Transactions and exceptions
            pazu

            You should *not* extend RuntimeException. Your app exceptions should descend from Exception or any other non-runtime exception you wish.

            If you exception extends RuntimeException, it will be wrapped in a EJBException and the client will be unable to catch it.

            • 3. Re: Transactions and exceptions
              onkalich

              When I tried to create application exception , the container did not catch the exception and roll back the transaction. As I looked at the code , the container catch only Runtime and Remote exception.

              • 4. Re: Transactions and exceptions
                bartmann_d

                That's because the container behaves according to the EJB spec! An application exception should not automatically lead to a rollback. If you want your bean to do so you have to explicitly set the rollbackOnly flag.