• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Why business method or home business method cannot throw RemoteException?

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nathaniel,
Thanks a lot. Your answer is straight and clear. Help me a lot!
Take care.

Hai
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
So there I was, trapped in the jungle. And at the last minute, I was saved by this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic