This week's book giveaway is in the Agile and Other Processes forum.We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!See this thread for details.

Home Business Methods

KRK Gowda

Ranch Hand

Posts: 132

posted 9 years ago

Hi All, I was going through HF EJB and found that, in an Entity bean code, home business methods do not declare Remote Exceptions. Whereas other methods like create method / finder method do declare exceptions. Can anybody tell me why home business methods cannot declare Remote Exceptions?

Thanks and Regards,

Awishek sinha

Ranch Hand

Posts: 62

posted 9 years ago

Hi Gowda Business method in the remote home interface required to throw java.rmi.remote exception

Awishek Kr Sinha<br />SCJP 1.4<br />SCBCD 1.3

KRK Gowda

Ranch Hand

Posts: 132

posted 9 years ago

oops, sorry. My question has to be like this Implementation of ejbCreate methods in session beans do not declare CreateException in bean code. Implementation of ejbCreate methods in entithy beans do declare CreateException in bean code. This i am not sure, i saw a piece of code in HFEJB, when i was reading chapter 5 - Entity bean synchronization. Is it really entity beans can declare exceptions(other than custom exceptions) when implementing create / finder methods in bean class.

Thanks and Regards

Awishek sinha

Ranch Hand

Posts: 62

posted 9 years ago

Hi Gowda The EJB spec says you must define CreateException in the throws clause of ejbCreate<method> the spec says page 192 10.6.4

The throws clause must define the javax.ejb.CreateException. The throws clause may define arbitrary application specific exceptions.

Awishek Kr Sinha<br />SCJP 1.4<br />SCBCD 1.3

Saurabh Chaubey

Ranch Hand

Posts: 101

posted 9 years ago

Hi Awishek, can you explain if the CreateExceptionshould also be declared in the throws clause of the Session Beans...or not.

Awishek sinha

Ranch Hand

Posts: 62

posted 9 years ago

CreateException for session bean is not mandatory the spec says page 96 7.10.3

The throws clause may define arbitrary application exceptions, possibly including the javax.ejb.CreateException