Goodday,
I am using
EJB 2.0 CMP Entity beans from within a Session bean.
I am getting a NoSuchEntityException on a given primary key, primaryKey. The code snippet is as follows:
try {
MTCEntityLocal mtcEntityLocal =
mtcEntityLocalHome.findByPrimaryKey(primaryKey);
MTCHistoryLocal mtcHistoryLocal =
mtcHistoryLocalHome.create(primaryKey, mtcEntityLocal);
}
catch (FinderException fe) {
// do something else
}
As you can see, the initialisation of the mtcHistoryLocal is dependent on the retrieval of the mtcEntityLocal entity bean. Therefore, if the entity does not exist we catch the FinderException and do something else.
And most of the time this works fine. In fact, I cannot replicate the problem, so I only have some server logs to go by. These state that a NoSuchEntityException is thrown when a 'get' method is called on mtcEntityLocal within mtcHistoryLocalHome.create(primaryKey, mtcEntityLocal)
I cannot understand why this might be, since there is no way through the application to remove the underlying data record; thus eliminating a concurrency problem.
All beans have <trans-attribute>Required</trans-attribute> in ejb-jar.xml so I'm thinking there should be no transactional problem.
Since the problem is intermittent, I have trouble investigating the state of the data when it occurs; when the problem does occur, a 2nd attempt is successful.
The application server is weblogic 8.1 and the database is Informix (not sure of the version).
Any help much appreciated.
Jim