• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

problem in throwing Exception from Bean

 
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
 
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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic