• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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?
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic