Win a copy of Head First Android this week in the Android forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

RemoveException vs RemoteException

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The real exam won't as the spec is the absolute authoritative document
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic