• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RemoveException vs RemoteException

 
Jason Hunt
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me what is the exception will be throwed in the following scenario:

Invoking javax.ejb.EJBHome.remove(java.lang.Object primaryKey) on a session bean.




 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you browse through the javax.ejb API, you will find the following information on the javax.ejb.EJBHome page:


remove
public void remove(java.lang.Object primaryKey)
throws java.rmi.RemoteException,
RemoveExceptionRemove an EJB object identified by its primary key.
This method can be used only for an entity bean. An attempt to call this method on a session bean will result in a RemoteException.

Throws:
RemoveException - Thrown if the enterprise Bean or the container does not allow the client to remove the object.
java.rmi.RemoteException - Thrown when the method failed due to a system-level failure.
 
Jason Hunt
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But from EJB Spec, you can find a different answer:

Page 59:
-----------------------------------------------------------------
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 .
-------------------------------------------------------------------

Page 60:
-----------------------------------------------------------------
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 .
------------------------------------------------------------------

I am really confused by the ejb javadoc and ejb spec.
[ July 21, 2004: Message edited by: Jason Hunt ]
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a good example of differences between the APIs and the spec. I've looked the Weblogic sources and the Weblogic container throws RemoveException when you try to invoke javax.ejb.EJBHome.remove(Object primaryKey) or javax.ejb.EJBLocalHome.remove(Object primaryKey) on a session bean, which means that the Weblogic server follows the spec. When in doubt, do the same, trust the spec, not the APIs as the comments might not have been properly adjusted when the spec changed

Hope this helps
 
Jason Hunt
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Valentin:

You really save my day, I encounter this in the mock test from ejbCertificate.com and that test choose RemoteException instead of RemoveException. So the only thing I hope is that the real exam won't have this problem. thanks again.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The real exam won't as the spec is the absolute authoritative document
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic