users@glassfish.java.net

Re: How to log "catched" Rollback exception within Stateless Session Bean

From: <glassfish_at_javadesktop.org>
Date: Fri, 24 Jul 2009 07:53:57 PDT

Thank you Matt.

I know about the transaction exception because I catch it within my web application, and I am able to see them in the Glassfish log file. I explain:

The client-side is a web application with this code

try {
    InvoiceClass invoice = remoteEJB.persistInvoice( newInvoice );
catch ( Exception ex ){
   logger( Level.INFO, "Error" + ex.getMessage(); )
}


The server-side is a stateless session bean implementing remote interface

public InvoiceClass persistInvoice( InvoiceClass newInvoice){
     try {
         entitiManager.persist( newInvoice );
     } catch( Exception ex ){
         logger.log(Level.INFO, "Error Persisting Invoice:" + ex.getMesssage() );
     }
}

I am testing the log on the EJB, so I send on purpose a newInvoice object that will cause a databaseException because of a duplicate key.

After sending the object, I am able to catch the RemoteException at the client-side, but not at the server-side, because the log message "Error persisting invoice" does not show in the Glassfish log file.

I donĀ“t know what I am missing.

Additionally, I am trying to catch the DatabaseException message, but looks that it is not possible within Container Managed Transaction.

Thank you.
[Message sent by forum member 'antoniojsg' (antoniojsg)]

http://forums.java.net/jive/thread.jspa?messageID=357437