Pages

Tuesday, March 2, 2010

Catching com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted exception

Hi!

If you want semantically clear application exception you should perform a flush() operation from inside the container-managed transaction at the moment just before you are ready to complete the method. It allows you to handle an exception while you are in control, without the container interfering (EJBException) and potentially worse - swallowing your persistence layer exception (go find it in container logs).

If you've got an exception from the flush() call, then you can catch it on the service layer and throw an application exception that the client can recognize.

Example:

try{
     manager.persist(relationshipDocumentType);
     manager.flush();

}catch (Exception e){
     ...
}


The exception will be catched and you will be able to do what you want.

No comments:

Post a Comment