How to catch Application Exception thrown from ejbStore


EJB programming & troubleshooting: How to catch Application Exception thrown from ejbStore

  1. Hi,
    I am working on application running on Iplanet Application Server 4.0. Problem is the application exception thrown from the ejbStore don't reach the calling servlet, calling servlet receive TransactionRollback exception which is system exception. But there is no sign of my application exception thrown from ejbStore. Can anybody tell me how I can get my ApplicationException thrown from ejbStore in my calling servlet.
    I am calling entity beans set method in servlet and in entity bean ejbStore method I am throwing Application exception.

    in entity bean

    public void ejbStore() throws MyException
    if(true) throw new MyException();


    in servlet

    try {
    MyEntityHome home = .......
    MyEntityRemote remote = home.findBy.....
    remote.setMyValue(MyValue value); //Transaction required Container managed

    }catch(MyException e) {
    e.printStackTrace(); // Not cahcing My Exception
    }catch(Exception e) {
    e.printStackTrace(); //catching TransactionRolledBackException
  2. Hi,
    The ejbStore should not throw any application exception as the programs that is part of the application is not going to make a call to the ejbStore method. The appliction programmer cannot control(decide) when ejbStore should be called. Generally, ejbStore is called at the end of the transaction, but it can also be controlled by various container specfic flags depanding on the sensitivity of the data (whether the data is read-only or read-write, etc).
    In your case, since ejbStore is made to throw an exception, the container intercepts the exception and rolls back the current TX and intimates the status of the entity to the client program by throwing TransactionRolledBack exception (a sub-class of RemoteException).