Hi,
I have a simple stateless session bean that has a method
that tries to access an entity bean, The entity bean has all method empty except ejbstore.
public void ejbStore() {
System.out.println("EntityBean.ejbStore()");
throw new EJBException("Lets see if i can catch this");
}
the method in session bean is :
public
String testEjbException(){
Context ctx;
try {
ctx = new InitialContext();
EntityHome home = (EntityHome)ctx.lookup("ejb/com/EntityHome");
home.create();
return "Created";
} catch (NamingException e) {
System.out.println(" Naming Exception() NamingException");
return "NamingException";
} catch (RemoteException e) {
System.out.println(" RemoteException");
return "RemoteException";
} catch (CreateException e) {
System.out.println(" CreateException");
return "CreateException";
}
catch (NoSuchEntityException e) {
System.out.println(" NoSuchEntityException");
return "EJBException";
}catch (EJBException e) {
System.out.println("EJBException");
return "EJBException";
}
}
But i am not able to catch this exception in the session bean.
Instead i get a TransactionRolledbackException Exception.
I am using WSAD 5.1.2
Can we catch EjbException this way?
Thanks and regards,
Shailesh