Hi Siva,
From
ejb core specification, 4.4.4 Restrictions for Transactions:
If a session bean instance is participating in a transaction, it is an error for a client to invoke the
remove method on the session object’s home or component interface object. The container
must detect such an attempt and throw the javax.ejb.RemoveException to the client.
The container should not mark the client’s transaction for rollback, thus allowing the client to
recover.
You can't remove a stateful session bean when the bean is participating in a transaction. Participating in a transaction not means that is on a new transaction opened in @Remove method. Stateful session beans can open a transaction in one method and close the transaction in another, it is posible only with BMT stateful beans, with CMT beans the transaction ends when the method ends and for that the bean no retain the transaction with it instance.
For example, see the next pseudo code, is a stateful session bean BMT that retain the transaction across two client methods calls
If the client do this secuences of call
refMySessionBean.method1()
refMySessionBean.remove() <--- throw a javax.ejb.RemoveException because the bean is participating on a transaction, that not is finished
This secuence must run fine:
refMySessionBean.method1()
refMySessionBean.method2()
refMySessionBean.remove()
Regards