Hi there, HFEJB says the if a client calls remove on bean thats already removed, you will get RemoteException or EJBException....(r Vs l ).
But I tried on entity as well as session bean... ...my client code is like this
address.remove(); // now address bean is removed....address is remote component interface
// now i call remove again. address.remove();
this gives me NoSuchObjectException
counter.remove(); // now counter session is removed //now i call remove again
this gives me NoSuchObjectException
Now under what situation does calling remove on already removed bean gives Remote or EJB exception?
I think there is a good reason why I'm getting NoSuchObjectException... when we call remove first, ejbobject dies on server...next time there is no such ejbobject to serve our remove...so its pretty acceptable.
Please clarify me if i'm missing something.... Amol
I don't have HF EJB with me, but I recal reading something about the vendor being free to throw more or less specific Remote exceptions.
In this case for NoSuchObjectException (which extends RemoteException) the vendor of your container has implemented it in order to give you back more detailed info, another vendor might chose to give back only RemoteException.
When I get hold of the book I'll try to confirm the above, unless someone else reads this first
Hi there, First of all thank you very much for considering a reply.
Yeah I also went through the Spec and HFEJB which says container is free to choose if it wants to give more specific exception. But I thought it was talking in context of exceptions like DuplicateKeyException which is a subclass of CreateException and ObjectNotFoundException which is subclass of FinderException.
But container must thorow NoSuchObjectException if there is no object for stub by client side.(I think).
Do you mean that my container is throwing me more Specific exception here? (NoSuchObjectException being subclass of RemoteException.)
May be your right.....but I still cant help fixin it up !!! Please clarify my view.
... container is free to choose if it wants to give more specific exception. But I thought it was talking in context of exceptions like DuplicateKeyException which is a subclass of CreateException and ObjectNotFoundException which is subclass of FinderException.
(see HF EJB p.550)
So what I've said in the previous post is not correct . Throwing the NoSuchObjectException is a requirement of the spec.
In the EJB specs (188.8.131.52) it says:
The java.rmi.NoSuchObjectException is a subclass of the java.rmi.RemoteException. It is thrown to the client if a remote business method cannot complete because the EJB object no longer exists.
When the client calls remove on the home or component interface to remove the session object, the container issues ejbRemove() on the bean instance. This ends the life of the session bean instance and the associated session object. Any subsequent attempt by its client to invoke the session object causes the java.rmi.NoSuchObjectException to be thrown if the client is a remote client, or the javax.ejb.NoSuchObjectLocalException if the client is a local client. (The java.rmi.NoSuchObjectException is a subclass of the java.rmi.RemoteException; the javax.ejb.NoSuchObjectLocalException is a subclass of the javax.ejb.EJBException). The ejbRemove() method cannot be called when the instance is participating in a transaction. An attempt to remove a session object while the object is in a transaction will cause the container to throw the javax.ejb.RemoveException to the client. Note that a container can also invoke the ejbRemove() method on the instance without a client call to remove the session object after the lifetime of the EJBobject has expired.
(see EJB spec 7.6.0)
I think that when HF EJB says you will get a RemoteException or a EJBException is technically correct, since these are superclasses of the more specific exceptions NoSuchObjectException and NoSuchObjectLocalException. But according to the specs I'd say the HF statement is not precise enough
What do you think?
Gian [ March 10, 2005: Message edited by: Gian Franco Casula ]
HI there, Again I must thank you for keeping on the discussion!!! In HFEJB,(I dont have book in hand , I'm in cafe)Ch. of Exceptions, there is a question in chapter(not chapter mock exam) which gives scenarios and in next column, lots of exceptions are also given which includes all Application(5) exceptins and System Exceptions too. But in answer it gives the RemoteException & EJBException as answers....while solving the exercise I selected NoSuchObjectException/local but I was wrong according to HFEJB. ......so now as you said HFEJB is not wrong but just not more specific in selecting its answer....but what if you are already given NoSuchObjectException in options too? Amol.
I see what you mean, the question can put one in a dilemma for what to chose. In order to give a consistent reply to the HF question, I guess saying the answer is RemoteException and EJBException is the best reply in this case.
Why? Because, since the client can be both remote and local (it's not specified in the question) the real exceptions thrown by the container are NoSuchObjectException and NoSuchObjectLocalException. These respecively implement RemoteException and EJBException.
Since NoSuchObjectLocalException is not provided as an answer, I'd say ticking both superclasses would be best