Hi,
I have a question regarding exceptions raised from within an EJB.

Context:
I want to raise application exceptions from within my session bean.
These will be caught by the
client (a servlet or a java application) and an appropriate error
message will be displayed to user. For instance, I want to throw a
ValidationException in response to an input parameter.

What I did:
So I declared my RemoteInterface as throwing both RemoteException &
CommonException.
ValidationException is a subclass of CommonException which in turn is a
subclass of java.lang.Exception.
Hence they are all serializable.
That is,
java.lang.Exception
|
+--mypackage.CommonException
 |
 +--mypackage.ValidationException

and
public businessMethod(serializable input)
throws RemoteException, CommonException;

Problem:
When I throw my ValidationException from the session bean, it travels
back to the client where I get the following:

java.rmi.UnexpectedException: Undeclared checked exception;

Now, I've checked that the Exception classes etc are on the classpath &
it is not a
ClassNotFoundException either. I read somewhere (don't remember where
:-()that if I have multiple business
exceptions, I can declare my business method to throw just the
superclass.

i.e instead of having my method declared as
public businessMethod(serializable input)
throws RemoteException, ValidationException, InvalidInputException, etc
etc...

just have
throws CommonException;

Is there a problem with this approach?

Can anyone help me with this UnexpectedException problem?
Some other things I tried:
1) I declared my remote interface to throw the actual exception
subclass - still got the same problem.
2) I declared my remote interface to throw java.lang.Exception - got
the same problem : but this time
I also got the error message string that I was setting on my bean.

Thanks in advance.
--Das

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to