Paul Sanghera wrotes in his book, that it is not necessary to declare a CreateException in the throws-clause of ejbCreate() and ejbPostCreate(), if you do not explicitly throw a CreateException in your code.
Hence I have removed all CreateExceptions from ejbCreate() and ejbPostCreate(). After that, I have deployed my beans again in JBoss, and now I will get the following warnings:
WARN [verifier] EJB spec violation: Method : public RecipePosPK ejbCreate(int, RecipePos) Section: 10.6.4 Warning: The throws clause must define the javax.ejb.CreateException.
Must I declare javax.ejb.CreateException in the throws-clause of ejbCreate() and ejbPostCreate(), even if I do not throw this exception?
Chapter 7 Session Bean Component Contract 7.10.3 ejbCreate<METHOD> methods The throws clause may define arbitrary application exceptions, possibly including the javax.ejb.CreateException.
Chapter 10 Entity Bean Component Contract for Container-Managed Persistence 10.6.4 ejbCreate<METHOD> methods The throws clause must define the javax.ejb.CreateException. The throws clause may define arbitrary application specific exceptions.
Chapter 12 Entity Bean Component Contract for Bean-Managed Persistence 12.2.3 ejbCreate<METHOD> methods The throws clause may define arbitrary application specific exceptions, including the javax.ejb.CreateException.
So the CMP Entity Bean ejbCreate and ejbPostCreate have to specify the CreateException in the throws clause. Session Bean and BMP Entity Beans may specifiy it.
Interestingly I also just yesterday ran across this little tidbit in Monson-Haefel's Enterprise JavaBeans 4e (p.78):
Although it's not required by the EJB specification, some J2EE application vendors insist that ejbCreate() throw a javax.ejb.CreateException - this is true of the J2EE 1.4 SDK. This has never been a requirement, but it's an issue that continues to crop up every time there is a new edition of the book.