You can throw EJBException, which is unchecked. CreateException is checked, which is not allowed. It's also for home interfaces, not JMS.
Well, I know that I can throw unchecked exceptions but this is a workaround.
The thing here is that the specification is vague by saying you can't throw application exceptions. The term "application exception" is left up to the interpretation of the implementation.
I would infer that you should be able to throw "non-application exceptions" which is not the same as unchecked exceptions, because they would have used this more precise term in the first place.
If you google for "message driven bean ejbcreate createexception" you would find some sample code from other appservers which shows that they allow CreateException.
Just because other app servers allow something doesn't make it right!
When you say "left up to the interpretation of the implementation", I assume you haven't read section 18.1.1 of the EJB (2.0) spec?
This case is clearly defined by the ejb 2.1 spec:
15.7.3 ejbCreate Method
The message-driven bean class must define one ejbCreate method whose signature must follow these rules:
The method name must be ejbCreate.
The method must be declared as public.
The method must not be declared as final or static.
The return type must be void.
The method must have no arguments.
The throws clause must not define any application exceptions.
18.1.1 Application Exceptions
An application exception is an exception defined in the throws clause of a method of an enterprise bean’s home, component, message listener, or web service endpoint interface, other than the java.rmi.RemoteException.
The javax.ejb.CreateException, javax.ejb.RemoveException, javax.ejb.FinderException, and subclasses thereof are considered to be application exceptions. These exceptions are used as standard application exceptions to report errors to the client from the create, remove,
and finder methods (see Subsections 10.5.9 and 12.1.10). These exceptions are covered by the rules on application exceptions that are defined in this chapter.
I had the same problem, the error was displayed even without the trows clause in the create method. I erased the throws clause from the ejbRemove method and everything worked just fine.
I don't understand this error, correct me if Ii'm wrong but the specification doesn't forbid to declare the ejbCreate method with the throws CreateException clause it forbids to actually throw the exception.