wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Why business method or home business method cannot throw RemoteException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Why business method or home business method cannot throw RemoteException? " Watch "Why business method or home business method cannot throw RemoteException? " New topic
Author

Why business method or home business method cannot throw RemoteException?

Hai Lin
Ranch Hand

Joined: May 23, 2004
Posts: 79
Hi, guys,
I cannot understand, since component interface has already declare the RemoteException, why the business method of the bean class, which implements the component interface, cannot declare the RemoteException?

Thanks a lot in advance?

Hai
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
A RemoteException should be used to indicate a network error, or something to that effect. Since your bean just implements business logic, it shouldn't be doing anything with RemoteExceptions. In addition, you don't know whether it will be a local or remote client anyways. If you need to throw an exception, wrap it in an EJBException and leave it at that.

As you mentioned, there's no reason why you couldn't throw a RemoteException, and the container probably wouldn't even notice if you did. But, the spec says don't do it --- so don't.

Oh -- and the bean doesn't implement the component interface. That's a no-no. Don't do that either -- even though technically you could.
[ July 11, 2004: Message edited by: Nathaniel Stoddard ]

Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Hai Lin
Ranch Hand

Joined: May 23, 2004
Posts: 79
Nathaniel,
Thanks a lot. Your answer is straight and clear. Help me a lot!
Take care.

Hai
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Also, as RemoteException is a checked exception, I'd expect the container to pass it to the client and not rollback the transaction. Is this the kind of scenario that a client can recover from?


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why business method or home business method cannot throw RemoteException?
 
Similar Threads
How to understand Passed by Reference or Copy of Value for Local or Remote Interface?
why EB can't throw RemoteException in Home Biz Methods?
HF EJB, question about page 86
SessionBean exceptions
Rules for component interface and home interface