• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Can a stateless bean throw a remote exception (Enthuware)?

Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is from Enthuware Test 1 Q1:

The important thing to remember is that FinderExceptions, CreateException, and RemoveException are checked application exceptions and must be declared in the throws clause of the method.

Also, beans are not allowed to throw RemoteException. It is the container's responsibility to throw it to the client if the client is a remote client.

Therefore, this code can only throw an EJBException, which is a RuntimeException.

However I wrote a quick test and the container (JBoss) did not have an issue with it:

Am I missing something here or is this merely a recommendation of the EJB3 specification?
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In EJB 3.0 with @Remote annotation business methods need not to to throw

If you throw, its no harm but in fact it is no required.
[ November 30, 2008: Message edited by: Chandra Bhatt ]
Enthuware Software Support
Posts: 4428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no Java langauge requirement that beans cannot throw RemoteException. So when you say that Beans are not allowed to throw RemoteException, it is not the compiler but the EJB specification that you are talking about. For example, if you say that a bean method is not allowed to call System.exit(0);, it means that the EJB specification forbids it, not Java language/compiler. So you can call System.exit(0) but, obviously, it would be a wrong thing to do.

Having said that, your confusion is valid and further clarification has been added to the explanation.
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic