users@glassfish.java.net

How to explicitly handle EJB3 exceptions?

From: <glassfish_at_javadesktop.org>
Date: Fri, 16 May 2008 00:39:01 PDT

Hi,

my understanding of how to deal with exceptions using EJB3 is incomplete
any hint and example is highly appreciated.

I have an MessageDrivenBean "MessageBean" which calls a SessionBean "OrderManagerBean". This OrderManagerBean has a "createOrder" method which is accessing several persistent entities. Both beans currently only utilize the default TransactionAttribute.

Currently, when the OrderManagerBean.createOrder fails to store an entity into the database, e.g. when a database constraint is violated, an unchecked exception is thrown *after* the OrderManagerBean.createOrder is returned, a rollback is performed and the message is resend to tbe MessageBean again and again.

My wish:
1) I like to explicitly handle a checked exception from the database just when OrderManagerBean.createOrder returns but not later.
2) When OrderManagerBean.createOrder has an error, processing inside my MessageBean should not rollback but send an reply message (through another JMS queue) with a business answer based on the caught exceptions from OrderManagerBean.createOrder.
[Message sent by forum member 'reiner_nix' (reiner_nix)]

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