0 Replies Latest reply on Jul 24, 2003 1:46 AM by hannwei

    JBoss UserTransaction - java.rmi.NotSuchObjectException

    hannwei

      Hi,

      I am using JBoss 3.0.x with Oracle8i. I have a multithreaded client program that uses entity beans on JBoss.

      A thread of the client program gets a UserTransaction reference, starts a transaction, creates an entity bean, and commits the transaction. This threads runs in a loop.

      Another thread waits at an object.

      A third thread starts a transaction, does a findBy....() and gets a collection of references of entity beans. It changes the state of each of those entity beans, whose references are in the collection. Then it commits the transaction. It passes keys of those entity beans to the second thread through some common in-memory repository, and notifies the second thread.

      The second thread starts a transaction uses a key to do getByPrimaryKey(), reads the data of the entity bean and removes the bean. Then it commits the transaction and goes back to wait again. If there are remaining keys in the repository, it proceeds to do the samething using the keys without waiting.

      The problem I face is that the third thread keeps getting java.rmi.NotSuchObjectException when it changes the state of the entity beans. This does not happen to all the entity beans, but a large proportion of them. I encountered the same problem when using JBoss 3.0.x with MySQL, and JBoss 2.4.3 with MySQL. With JBoss 2.4.3, there were other problems. Is there anything that has been missed that results in this problem?

      With JBoss 2.4.3, I have even encountered cases in which findByPrimaryKey() gives ObjectNotFoundException for objects that were found in a transaction by some other thread a while ago. When findByPrimaryKey() succeeds, an attempt to remove the entity bean with bean.remove() could result in ObjectNotFoundException. Is this normal? I am quite sure that there is no other place in the client program that removes entity beans, other than the second thread mentioned above. Is this a known JBoss problem? Or is it due to some logic problem in the client program that I have not discovered?

      Besides, I noticed that the client program gets an exception when it creates an entity bean, saying that a transaction does not exist. The entity bean has a mandatory transaction requirement. And the program logic states very clearly that transaction.begin() is invoked by the thread before the same thread creates the entity bean. This happens very often, and only happens to the first few transactions. It appears in JBoss 3.0.x, but seldom or not in JBoss 2.4.x. Is this a JBoss problem?

      Thanks.


      Hann Wei