Hi there, quick question for the forum:
Say I have a bean class, MyBean, in which I have a biz-logic method, MyMethod. MyMethod throws a MyException class exception if something goes wrong.
The problem I'm wrestling with is that MyBean's remote interface only allows me to define MyMethod as throwing a RemoteException. As such, the client only sees RemoteException's and not MyException's. What piece of the puzzle am I missing to get the MyException class thrown to the client?
I would be most grateful for any advice.
Regards,
William Lin
william.w.lin@gs.com
-
need help on bean exception throwing/handling design (3 messages)
- Posted by: William Lin
- Posted on: August 22 2000 10:53 EDT
Threaded Messages (3)
- need help on bean exception throwing/handling design by Floyd Marinescu on August 22 2000 13:13 EDT
- need help on bean exception throwing/handling design by Pratap Das on August 24 2000 00:00 EDT
- need help on bean exception throwing/handling design by Floyd Marinescu on August 24 2000 03:58 EDT
- need help on bean exception throwing/handling design by Pratap Das on August 24 2000 00:00 EDT
-
need help on bean exception throwing/handling design[ Go to top ]
- Posted by: Floyd Marinescu
- Posted on: August 22 2000 13:13 EDT
- in response to William Lin
William, there is no restriction on supplying business specific exceptions, infact they are very important to building a good system.
Your beans can throw any number of exceptions of any type, as long as they (and RemoteException) are declared in the remote interface, and your client has these exceptions in his classpath.
The practise I follow is to make my own business exceptions for my business needs, and throw EJBException for any system level failure (the app. server should wrap EJBException as a RemoteException for the client.
Floyd -
need help on bean exception throwing/handling design[ Go to top ]
- Posted by: Pratap Das
- Posted on: August 24 2000 00:00 EDT
- in response to Floyd Marinescu
Floyd,
In your RemoteInterface do you throw each individual business exception or do you throw a common superclass of the business exception? For instance, do you use
public myBusinessMethod() throws RemoteException, BizException1, BizException2, BizException3 ....;
or, do you have a common superclass for all the BizExceptions like say CommonBizException & declare your remote interface as
public myBusinessMethod() throws RemoteException, CommonBizException;
Will this design work?
--Das -
need help on bean exception throwing/handling design[ Go to top ]
- Posted by: Floyd Marinescu
- Posted on: August 24 2000 15:58 EDT
- in response to Pratap Das
Pratap,
I throw each business exception separatly, however there is no reason why you shouldn't be able to throw a common super class of a business exception.
The only bad part about the superclass method is the extra code you will have to write on the client side to determine exactly which business exception the superclass represents.
Floyd