Hi fellow nitpickers. Agreed it's pretty trival and, honestly, I've searched this forum and the errata but.. -the EJB 2.0 Spec (Final Release Aug 14 2001) states in section 10.6.4 ejbCreate<METHOD> methods (for CMP that) 'The throws clause *must* define the javax.ejb.CreateException.' - Head First EJB (Oct 2003 First Ed) says on p333 Rules for ejbCreate 'You *may* declare a throws clause with CreateException' The code examples on pp316,318,331,335 have no such exception. Presumably the Spec is the definitive answer but is one really expected to know such details for the exam? Frightening.
I noticed that too. Not sure if it is a rule, or just bad wording of that portion of the spec. CreateException is an application exception, and other parts of the spec have the usual discussion about exceptions declared in the implementation method need to be declared in the appropriate interfaces. That CreateException rule seemed an odd departure.
Reid - SCJP2 (April 2002)
posted 16 years ago
Reid I tested this point on the Sun 1.4 RI and omitting the CreateException on ejbCreate gives a deploy error to that effect. HoweverI'm not downloading 1.3 just to confirm. I guess the point is to regard the Spec as the definitive statement even if it seems odd or contradicts other sources. It would be pleasing to have this paticular discrepancy between the spec and the Head First EJB text confirmed. Ordinarily there seems little point in raising a simple typo where there is no risk of misunderstanding e.g on p304 the call to ejbSelectGetAllMovies has no argument but the corresponding EJB QL uses a parameter. However compilers of mock, and perhaps real, exam questions seem, for some reason, to be very keen on the exceptions raised by methods and their optionality e.g p290 Q10, p363 Q5, Q6