This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Is CreateException, FinderException, RemoveException and EJBException applicable to their respective methods? Say CreateException is thorwn when problems in creating a bean instance and finder when canno find bean due to (maybe connection or sql error) etc. RemoveException when ejbRemove encounter problems and EJBException when business methods cannot succeed? In sun tutorial all methods throw EjbException which confused me. Could someone shed some light on this issue please? Thanks a lot Rastin
EJBExcpetion is a runtime exception so you do not have to declare it in the throws clause. (It is also a wrapper exception....) The tutorial is wrong. Doing such will cause the verifier in deploytool to declare this as an error. All system exceptions are runtime exceptions in EJB. If you the container encounters a system exception, it will automagically role back the current transaction. CreateException and RemoveException are application exceptions (non system, i.e., non runtimes). If the container encounters them, it will not automagiacally role back the current transaction.... it is up to the client if the transaction context gets propagated that far to handle the exception and roll back the transaction if needed.