Lets say for some reason ejbCreate() in a SLSB needs to throw a CreateException. How does it reach to the client?
I believe this is what happens. Correct me if I am wrong. The Conatiner translates that into a RemoteException for the client. So what you see on the client side is a javax.rmi.RemoteException
thanks for the response.
However, the issue is different.
Firstly, CreateException is an application exception while RemoteException falls into system exception. According to the specification, "An application exception thrown by an enterprise bean instance should be reported to the client
precisely (i.e., the client gets the same exception)." -18.1.2
So I guess the client would get CreateException. But the real issue is how does it get it. ejbCreate() on a SLSB is called much before any client calls create, i.e., when the bean goes from "does not exist" to "method-ready pool".
So the question is if ejbCreate() throws a CreateException what happens to that bean and how does it propagate to the client ?
Client will get CreateException, whether actually ejbCreate
is called before/after is not a concern,I guess the
container may make a retry if the pool is empty..
thanks for the response.
What happens to the bean instance ? Is it valid ? The client would assume that it is valid since CreateException is an application exception and therefore should be able to call any business method . Is this right?
Not really, although CreateException is an application exception, in the context of ejbCreate(), it means the
bean instance is not created/valid.
This is interesting. CreateException is usually thrown only in the context of ejbCreate(), then what is the point of defining CreateException as an application exception ?
I donot see anything in the specification on CreateException in regard to session bean. Neither is anything on what you said in your last post. In fact, wrt entity bean, it clearly states "The Container treats the CreateException as any other application exception." - 10.5.8.1(CMP) and 184.108.40.206(BMP)
I really didn't see the conflict here..
CreateException is an application exception .. peroid.
If the client get a CreateException, it means the bean
instance or the container have problems during the
ejbCreate phrase and such problems are application level,
for example wrong parameter, duplicate key(EB only)...
the whole transaction may not need to be roll back and
you may still retry.
The client would assume that it is valid since CreateException is an application exception and therefore should be able to call any business method .
Although the spec doesn't explictly say that, it is a
common sense not to do that.
There are two ways to exit a java method: do a return or throw a exception; they are mutal exclusive. So when
create exception got thrown, same time the object didn't
get returned, how can you use this non-exist object
From the latest ejb 2.0 draft spec,
section 7.10.6 session bean's remote home interface:
"The throws clause must include java.ejb.CreateException"
thanks for clarifying.
i was confusing ejbCreate() with other business methods where the bean instance is still valid even if you get an application exception. But, here you donot get the EJBObject because of CreateException and hence doesnot make sense to use to subsequently.