• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

RemoveException vs RemoteException

 
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.




 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • 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
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • 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
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The real exam won't as the spec is the absolute authoritative document
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic