Rivka, I'll add to this:

Pick up "Core J2EE Patterns" from Sun. It is worth the money and will help you.

My solution would be similar to what Ed said. I would use a "manager" class 
(aka "business facade", "business delegate", "service manager", etc. although 
each one of these may mean something slightly different) to decouple Struts 
from your EJB layer. Struts actions talk to the manager only. The manager 
methods (typically logon + C.R.U.D. + search -- general user actions) throw 
SystemException and ApplicationException only. Struts is configured to handle 
these (or subclasses of these) declaratively (or else try/catch for these two 
in your Action class if you haven't gone declarative yet). Struts then knows 
nothing about RemoteException and other specific Exceptions like that. It only 
has to worry about two Exception types (but can go finer grained by handling 
subclasses of these when you are ready). Meanwhile your manager class (or some 
data access object/manager behind the main manager) handles try/catch for 
RemoteException, EJB Exception, etc. If manager cannot do his job, he either 
throws SystemException or ApplicationException at the "user" (Struts).

Erik


-----Original Message-----
From: Ed Griebel <[EMAIL PROTECTED]>
Sent: Jul 20, 2005 9:19 AM
To: Struts Users Mailing List <user@struts.apache.org>
Subject: Re: ApplicationException sample

Rivka-

Since you're developing from scratch, you might want to put a layer
in-between your EJBs and Struts. Some will call it business logic,
data access object (DAO), or Helper classes. This allows you to
separate the struts-related concerns from business-related concerns.
It also solves the issue you mentioned about where to catch
RemoteExceptions. Also, these helper classes can be used in more than
one action which could be a benefit.

A quick and dirty fix to your problem would be to declare the
execute() method in your action to also throw a RemoteException, and
then declaratively handle the exception in your Struts config inside
<global-exceptions>. I'd only use this if there's no way for you to
recover the transaction when a remoteException occurs. It's an old
article, but take a look at
http://www.onjava.com/pub/a/onjava/2002/10/30/jakarta.html. These
sites are good for starting out in struts too:
http://husted.com/struts/ and http://www.reumann.net/struts/main.do

Good luck,
-ed

On 7/20/05, Rivka Shisman <[EMAIL PROTECTED]> wrote:
> 
> Erik, Glen, Laurie - Thanks for your help
> 
> After doing some more homework about exception handling - I have another
> question:
> 
> If my Sturts Action calls directly to EJB methods (with no delegate
> Layer) - then I have to catch RemoteException for all runtime
> exceptions? Or is there a better way to work?
> 
> Thanks
> Rivka
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to