Object has been removed or recycled

I have a loop in the Java agent to loop through all the documents in a view. In order to avoid out of handle error, I recycle document before looping back. This is the section of my code:

doc = view.getFirstDocument();

while (doc != null) {

vDocUIDs.addElement(doc.getUniversalID());

tempDoc = doc;

doc = view.getNextDocument(tempDoc);

tempDoc.recycle();

}

For most of time, it runs fine. However, sometimes I do get the exception:

0D60:0035-08D8] 08/04/2004 12:20:21 PM HTTP JVM: NotesException: Object has been removed or recycled

[0D60:0035-08D8] 08/04/2004 12:20:21 PM HTTP JVM: at lotus.domino.local.NotesBase.CheckObject(NotesBase.java:1249)

[0D60:0035-08D8] 08/04/2004 12:20:21 PM HTTP JVM: at lotus.domino.local.Document.getUniversalID(Unknown Source)

Any idea?