Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session bean question

 
Sunjeev Shetty
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
given a valid reference to a stateless session object remote home interface called paymentHome and this valid client code

try{
PaymentService pymt=paymentHome.create();
pymt.processPayment();
pymt.remove();
}
catch (javax.ejb.CreateException exc){
exc.printStackTrace();
}

Assume that the EJB remote component interface does NOT throw any application specific exceptions which two additional exceptions does this code need to handle?
1.java.ejb.EJBException
2.java.rmi.RemoteException
3.javax.ejb.RemoveException
4.javax.ejb.FinderException
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FinderException would not apply since this is not entity bean.

RemoveException would also not apply since this is STATELESS SB.

So the remaining two options - 1 and 2 should be right. Is this correct answer?
 
Sunjeev Shetty
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ankit.I thought 2 and 3 were the right answers.Why would RemoveException not apply?
[ April 13, 2006: Message edited by: Sunjeev Shetty ]
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

First of all, answer 1 is NOT correct. EJBException is an unchecked exception, so there's no need to handle it.
2 is correct, because all methods may throw such an exception.
3 is correct, it may be thrown from the remove method (Session and Entity beans)
4 is incorrect, it's only for finder methods.

So correct answers : 2 and 3.
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, just tried this over a sample client ...

I was thinking from the container's perspective ...

yeah, since the RemoveException is checked exception, it would have to be caught by the client ... this would be compile-time check and the client would not compile at all if you don't catch the RemoveException

But, for SLSB can there be a scenario in which the RemoveException would actually be thrown back to the client?
 
Prashant Tejura
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreed that for SLSB, remove() doesn't force the Container to invoke ejbRemove().

But there is only one common EJBObject interface thats applicable for both SFSB and SLSB where method remove() is defined as follows:-

public void remove() throws RemoteException,RemoveException
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreed, got that point.

Just wanted to clarify the other thing - will there be any scenario with SLSB in which the RemoveException will actually be thrown back to the client?
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can someone please confirm this?

Whether there can be any scenario with SLSB in which the RemoveException will actually be thrown back to the client?
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so, I cannot think of such a scenario. But it is technically possible.
 
Sunjeev Shetty
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to HF page 550 stateless session bean clients will never get RemoveException.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic