Search code examples
javajava-ee-5

Why EJBObject's remove function no removing the object of the Collection get from bmp-query?


BG: My company is using some old java technology. We have weblogic server. We have interface which extends the EJBHome, used to run query in database to retrieve Collection of/Simply the EJBObject.

I get a problem, for which all happen within one method. Basically it is described as follow:

  1. I run bmp-query to get a Collection of Object
  2. I loop through the Collection and decide to run the remove method in the EJBObject for some of it.
  3. I loop through the Collection again, and cast each of it to be some extended type of EJBObject

Then, I get a NoSuchObjectException.

The tricky thing is the problem happen in weblogic server, but is not happening in local environment.

By removing the .remove() line of code. This problem will not be happened. I am pretty sure that it related to the RMI kind of concept. However, I am difficult to find any explanation on the web.

Could anyone explain/give the reference for me to explore the answer?


Solution

  • As suggested by Thomas. The Collection storing the addresses of the Object, but the remove function is deleting the actual memory of the remote object. As a result, the address points to no Object.