Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

session bean's ejbRemove() and RemoveException

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got a question for you guys:

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.
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle,

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)

EJBLocalHome:
1] remove(Object primaryKey)

EJBObject:
1] remove()

EJBLocalObject:
1] remove()

Hope this helps.
[ November 17, 2004: Message edited by: Sandesh Tathare ]
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think both of you are right...

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.
 
Kyle Tang
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot guys. That cleared things out.
 
Whatever you say buddy! And I believe this tiny ad too:
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