sankara rao bhogi wrote:
> glassfish_at_javadesktop.org wrote:
>
>> 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.
>>
>
>
> Not sure, if you can manage to catch RollbackException in the case of
> CMT. Transaction commit/rollback happens after the business method has
> finished its execution, so you can intercept. What you can do is,
> implement SessionSynchronization call back, which will tell you whether
> transaction has been committed or rolled back.
Another option would be to call em.flush().
There is an open bug to add all chained exceptions to the RollbackException that
you get on the caller. When it is fixed, you'll be able to navigate to the
SQLException at the root of the problem.
Regards,
-marina
>
> regards
> sankar
>
>> Thank you.
>> [Message sent by forum member 'antoniojsg' (antoniojsg)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=357437
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>