java 托管服务器 bean 崩溃

java managed server bean crashes

为什么我不能多次调用它?

 private Document getStationery(String txtStationery,Database mailDB){
      try {
        View mailView = mailDB.getView("(Stationery)");
        DocumentCollection dc = mailView.getAllDocumentsByKey("Memo Stationery");
        Document tmpdoc;
          Document doc = dc.getFirstDocument();
          while (doc != null) {
             if(doc.getItemValueString("MailStationeryName").equals(txtStationery))
            {
                return doc;
            }
            tmpdoc = dc.getNextDocument();
            doc.recycle();
            doc = tmpdoc;
          }
         
    } catch (NotesException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
      
  }

下面第二次使用时崩溃....与不回收有关?

public void send() throws NotesException, IOException, Exception{
    Session session = getCurrentSession();
    Database userDB = getUserDatabase();
    Database mailbox = session.getDatabase("", "mail1.box");
    Document stationeryDoc1 = getStationery("Test1",userDB);
    Document stationeryDoc2 = getStationery("Test2",userDB);

您可以尝试完全不回收(通常不是一个好主意,但在这里排除其他问题可能会有所帮助),或者正确回收 getStationary() 方法中的对象,从 Document 开始, DocumentCollection,最后是 View。目前,您唯一回收的对象是 while 循环中的前一个 Document 对象。