Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in throwing Exception from Bean

 
Poornachandran R
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
Following lines will depict my situation.
Servlet
-------
try {
invokes...the m1 method in the EJB Bean.
} catch(ABCException ae) {
System.out.println("in abc catch");
} catch(RemoteException re) {
System.out.println("in remote catch");
}
EJB Bean
--------
m1() throws ABCException, RemoteException {
dao invoking code
}
DAOImpl
-------
m1() throws ABCException {
try {
db access code here....
} catch(Exception e) {
throw new ABCException("relevant msg");
}
}
If there is an error in DAOImpl...it throws the ABCException to Bean and inturn the same is thrown to Servlet.
But the problem is, In Servlet...i am getting the output....
"in remote catch"
Can anybody say why it is so ?
Note : My ABCException extends EJBException.
Poorna
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the expected behavior.
The problem is, EJBException is a subclass of RuntimeException and hence NOT considered an application exception by the container.
If you want the exception to be propagated to (Servlet)client in its original shape and form, it has to be an application exception. EJB spec requires all application exceptions to be direct subclass of java.lang.Exception.
[ April 30, 2003: Message edited by: Ajith Kallambella ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic