Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exceptions

 
Sahul Yasin
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Is there any difference in the following scnearios. Pls explain me.

SessionBean calls getPrimaryKey() on its context - IllegalStateException(HFEJB: Page 560)
Client Calls SessionBean getPrimaryKey() on the EJBObject - RemoteException(HFEJB: Page 559)

Thanks & Regards,
Yasin
[ February 25, 2006: Message edited by: Yasin S ]
 
Mahesh Subramanian
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understood it, Remote client does not get Runtime exceptions from remote EJB object. So it has to get a RemoteException (or subclass) instead of IllegalStateException which is a RuntimeException.
 
Balaji Anand
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes...there are 2 things in exception
bean->container->client
when the bean throws a IllegalStateException or any of the other SystemException the client sees it as either RemoteException or EJBException based on if it is remote or local. The client cant do anything useful with the system exception details.
Page 559 is what the client sees an page 560 is what the bean throws.
Hope this helps
 
MI Mohammed
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, if you look at EJBContext interface there is no getPrimaryKey(), so any attempt to call getPrimaryKey() using it's sub interface ie SessionContext object, you can't help it but get a fat java.lang.IllegalStateException.

On the second part, Session beans don't have primary key. but EJBObject interface has a getPrimaryKey(). So, when you call EJBObject.getPrimaryKey() on a session bean, for local client you javax.ejb.EJBException and remote client, java.rmi.RemoteException. Just look at this code


I think it's kind of Runtime Exception that is actually thrown from the background.

Whew, hope it helps.
 
Sahul Yasin
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Thanks for the replies. I have just taken the exam, scored 88%.

Regards,
Yasin
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic