Forums Register Login

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

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
In EJB 3.0 with @Remote annotation business methods need not to to throw
java.rim.RemoteException.

If you throw, its no harm but in fact it is no required.
[ November 30, 2008: Message edited by: Chandra Bhatt ]
+Pie Number of slices to send: Send
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.
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2125 times.
Similar Threads
ejb create() Error java.lang. IllegalStateEx: Failed to find method for hash
RMI server startup exception
Mikalai Zaikin SCBCD5.0 example problem
Stub cannot be cast to Interface
Calling EJB from servlet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:42:00.