This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why business method or home business method cannot throw RemoteException?

 
Hai Lin
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Hai Lin
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nathaniel,
Thanks a lot. Your answer is straight and clear. Help me a lot!
Take care.

Hai
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic