This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
according to API, SessionBean.ejbRemove() does NOT throw RemoveException. So, can a client get RemoveException when calling any remove() method on a session bean?
Thanks.
my guess is it will never get RemoveException for session bean.
my guess is it will never get RemoveException for session bean.
RemoveException for Session Beans is thrown in following cases:
1] Because session objects do not have primary keys that are accessible to clients, invoking the javax.ejb.EJBHome.remove(Object primaryKey) method on a session results in the javax.ejb.RemoveException. (Refer to section 6.3.2 Removing a session object of EJB 2.0 specification)
2] Because session objects do not have primary keys that are accessible to clients, invoking the javax.ejb.EJBLocalHome.remove(Object primaryKey) method on a session results in the javax.ejb.RemoveException. (Refer to section 6.4.2 Removing a session object of EJB 2.0 specification)
3] 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. (Refer to section 7.6.4 Restrictions for transactions of EJB 2.0 specification)
Remember, RemoveException is declared in throws clause of following methods: EJBHome: 1] remove(Handle handle) and 2] remove(Object primaryKey)
The remove()behaves different for Stateful & Stateless session beans.
In Stateful session beans the client can get the javax.ejb.RemoveException becuase clinet calls the remove() hence ejbRemove() is called on bean here the EJBObject is directly related to Bean Instance throu out the session of client.
But if the case is Stateless Session Bean then the client is not responsible for calling ejbRemove() of the bean it will be called by container when it wants to do depending on load or other criterias, so the client will never get this type of Exception even if the client call remove() on stateless session bean. i.e. Here remove() will never call ejbRemove() on bean instance.
Thanks!! Sandy
Sandesh Tathare
Ranch Hand
Joined: Jun 22, 2003
Posts: 82
posted
0
Sandy,
client will never get this type of Exception even if the client call remove() on stateless session bean.
Client would get RemoveException, if client calls remove(Object PK) on Stateless Session Bean. I have tried this out.
Sandy...when remove() is called on the remote interface, ejbRemove() never gets called for a stateless session bean and hence, no RemoveException is thrown.
Sandesh...since stateless session beans do not have a primary key, calling remove (Object PK) would throw a RemoveException.