aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Exceptions" Watch "Exceptions" New topic
Author

Exceptions

Sahul Yasin
Ranch Hand

Joined: Aug 28, 2002
Posts: 48
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 ]

Regards,<br />Yasin<br />SCJP,SCWCD,SCBCD
Mahesh Subramanian
Greenhorn

Joined: Feb 25, 2006
Posts: 6
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

Joined: Nov 03, 2004
Posts: 146
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

Joined: Feb 16, 2005
Posts: 146
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.


SCJA(Beta) SCJP 1.4 SCWCD 1.4 SCBCD 1.3 SCBCD 5.0 beta <br />The more practice we get, the better we are at the exams and in life in general. Pls join me at My DEN.
Sahul Yasin
Ranch Hand

Joined: Aug 28, 2002
Posts: 48
Hi All,

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

Regards,
Yasin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exceptions