This discussion is archived
2 Replies Latest reply: Mar 15, 2012 3:30 PM by EJP RSS

Error: This operation is not allowed on a closed folder

923147 Newbie
Currently Being Moderated
Hi,

I am using Javamail to deposit messages in bulk via IMAP.
Looking forward for some Input.. Thanks

I am able to get the Store for IMAP and the IMAP Folder too while accessing it through multiple threads for multiple users . However, while trying to close the IMAPFolder at the end of the call I am getting the below error.

Error:
====
java.lang.IllegalStateException: This operation is not allowed on a closed folder
     at com.sun.mail.imap.IMAPFolder.close(IMAPFolder.java:1074)
     at com.sun.mail.imap.IMAPFolder.close(IMAPFolder.java:1050)
     at com.agnity.vm.mssAdaptor.provider.MessageProviderImpl.disconnectFromInbox(MessageProviderImpl.java:335)
.....

Source Code Snippet:
=========

try {
               if (imapFolder != null && imapFolder.isOpen()) {
                    imapFolder.close(true);                    
               }
          } catch (MessagingException msgEx) {
               msgEx.printStackTrace();
          } finally {
               try {
                    if (imapStore.isConnected()) {
                         imapStore.close();                         
                    }

               } catch (MessagingException e) {
                    e.printStackTrace();
               }
          }

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points