classpathx-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Classpathx-discuss] Which application uses GNU JavaMail ?


From: Cedric Hyppolite
Subject: Re: [Classpathx-discuss] Which application uses GNU JavaMail ?
Date: Sat, 11 Feb 2006 13:51:31 +0100

Hi Chris,

Here is a test that shows the issues and the log. I cut the irrelevant part of the stack trace.
I ran this test under MacOSX with Eclipse compiler and SUN JVM 1.4.2.

Regards,
Cedric

========== TestCase =============
import java.util.Properties;

import javax.mail.Folder;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;

import junit.framework.TestCase;

public class IMAPFolderTest extends TestCase {
        public void testIMAPFolder() throws MessagingException {
                String host = "XXX";          
                String username = "XXX";
                String password = "XXX";
                
                Properties props = new Properties();
                Store store;
                Session session;
                session = Session.getDefaultInstance(props, null);
                
                session.setDebug(true);
                store = session.getStore("imap");
                store.connect(host, username, password);
                System.out.println("Listing Personal namespaces");
                try {
                        // This will succeed.
                        listFolders(store.getPersonalNamespaces());
                        if (store.getPersonalNamespaces().length > 0) {
                                
listSubFolders(store.getPersonalNamespaces()[0]);
                        }
                } catch (Exception e) {
                        System.err.println("Error getting personal namespaces");
                        e.printStackTrace();                    
                }

                System.out.println("Listing Shared namespaces");
                try {
                        // This will fail.
                        listFolders(store.getSharedNamespaces());
                } catch (Exception e) {
                        System.err.println("Error getting shared namespaces");
                        e.printStackTrace();                    
                }
                
                System.out.println("Listing User namespaces");
                try {
                        // This will succeed.
                        listFolders(store.getUserNamespaces(username));
                } catch (Exception e) {
                        System.err.println("Error getting user namespaces");
                        e.printStackTrace();                    
                }
                
                Folder folder = null;
                try {
                        // This will fail.
                        folder = store.getDefaultFolder();
                        folder.open(Folder.READ_ONLY);
                        listSubFolders(folder);
                        folder.close(false);
                } catch (MessagingException e){
                        System.err.println("Failed to open default folder as 
read-only");
                        e.printStackTrace();                    
                }

                try {
                        // This will fail.
                        folder = store.getDefaultFolder();
                        folder.open(Folder.READ_WRITE);
                        listSubFolders(folder);
                        folder.close(false);
                } catch (MessagingException e){
                        System.err.println("Failed to open default folder as 
read-write");
                        e.printStackTrace();                    
                }
                try {
                        // This will fail.
                        folder = store.getFolder("");
                        folder.open(Folder.READ_ONLY);
                        listSubFolders(folder);
                        folder.close(false);
                } catch (MessagingException e){
System.err.println("Failed to open 'empty name' folder as read- only");
                        e.printStackTrace();                    
                }
                try {
                        // This will fail.
                        folder = store.getFolder("");
                        folder.open(Folder.READ_WRITE);
                        listSubFolders(folder);
                        folder.close(false);
                } catch (MessagingException e){
System.err.println("Failed to open 'empty name' folder as read- write");
                        e.printStackTrace();                    
                }
                try {
                        // This will succeed.
                        folder = store.getFolder("INBOX");
                        folder.open(Folder.READ_ONLY);
                        listSubFolders(folder);
                        folder.close(false);
                } catch (MessagingException e){
                        System.err.println("Failed to open 'INBOX' folder as 
read-only");
                        e.printStackTrace();
                }
                try {
                        // This will succeed.
                        folder = store.getFolder("INBOX");
                        folder.open(Folder.READ_WRITE);
                        listSubFolders(folder);
                        folder.close(false);
                } catch (MessagingException e){
                        System.err.println("Failed to open 'INBOX' folder as 
read-write");
                        e.printStackTrace();
                }
        }
        
        private void listSubFolders(Folder folder) throws MessagingException {
System.out.println("Folder " + folder.getFullName() + " type is " + folder.getType());
                if ((folder.getType() & Folder.HOLDS_FOLDERS) == 0) {
                        
System.out.println("Folder " + folder.getFullName() + " cannot contain subfolders.");
                        return;
                }
                System.out.println("Listing sub folders of " + 
folder.getFullName());
                listFolders(folder.list());
        }               
        
        private void listFolders(Folder[]array) {
                for (int i = 0 ; i < array.length ; i++) {
                        Folder folder = array[i];
                        System.out.println("Found folder " 
+folder.getFullName());
                        
                }
        }
}
============= LOG FILE ================
Listing Personal namespaces
Found folder ~
Folder ~ type is 2
Listing sub folders of ~
Listing Shared namespaces
Error getting shared namespaces
java.lang.NullPointerException
at gnu.mail.providers.imap.IMAPStore.getSharedNamespaces (IMAPStore.java:486) at org.humannetwork.net.mail.IMAPFolderTest.testIMAPFolder (IMAPFolderTest.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
...
Listing User namespaces
Failed to open default folder as read-only
javax.mail.MessagingException: EXAMINE failed: Can't open mailbox : no such mailbox;
  nested exception is:
gnu.inet.imap.IMAPException: EXAMINE failed: Can't open mailbox : no such mailbox
        at gnu.mail.providers.imap.IMAPFolder.open(IMAPFolder.java:357)
at org.humannetwork.net.mail.IMAPFolderTest.testIMAPFolder (IMAPFolderTest.java:59)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
...
nested exception is:
gnu.inet.imap.IMAPException: EXAMINE failed: Can't open mailbox : no such mailbox
        at gnu.inet.imap.IMAPConnection.selectImpl(IMAPConnection.java:867)
        at gnu.inet.imap.IMAPConnection.examine(IMAPConnection.java:833)
        at gnu.mail.providers.imap.IMAPFolder.open(IMAPFolder.java:341)
at org.humannetwork.net.mail.IMAPFolderTest.testIMAPFolder (IMAPFolderTest.java:59)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
...
Failed to open default folder as read-write
javax.mail.MessagingException: SELECT failed: Can't open mailbox : no such mailbox;
  nested exception is:
gnu.inet.imap.IMAPException: SELECT failed: Can't open mailbox : no such mailbox
        at gnu.mail.providers.imap.IMAPFolder.open(IMAPFolder.java:357)
at org.humannetwork.net.mail.IMAPFolderTest.testIMAPFolder (IMAPFolderTest.java:70)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
...
nested exception is:
gnu.inet.imap.IMAPException: SELECT failed: Can't open mailbox : no such mailbox
        at gnu.inet.imap.IMAPConnection.selectImpl(IMAPConnection.java:867)
        at gnu.inet.imap.IMAPConnection.select(IMAPConnection.java:821)
        at gnu.mail.providers.imap.IMAPFolder.open(IMAPFolder.java:338)
at org.humannetwork.net.mail.IMAPFolderTest.testIMAPFolder (IMAPFolderTest.java:70)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
...
Failed to open 'empty name' folder as read-only
javax.mail.MessagingException: EXAMINE failed: Can't open mailbox : no such mailbox;
  nested exception is:
gnu.inet.imap.IMAPException: EXAMINE failed: Can't open mailbox : no such mailbox
        at gnu.mail.providers.imap.IMAPFolder.open(IMAPFolder.java:357)
at org.humannetwork.net.mail.IMAPFolderTest.testIMAPFolder (IMAPFolderTest.java:80)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
...
nested exception is:
gnu.inet.imap.IMAPException: EXAMINE failed: Can't open mailbox : no such mailbox
        at gnu.inet.imap.IMAPConnection.selectImpl(IMAPConnection.java:867)
        at gnu.inet.imap.IMAPConnection.examine(IMAPConnection.java:833)
        at gnu.mail.providers.imap.IMAPFolder.open(IMAPFolder.java:341)
at org.humannetwork.net.mail.IMAPFolderTest.testIMAPFolder (IMAPFolderTest.java:80)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
...
Failed to open 'empty name' folder as read-write
javax.mail.MessagingException: SELECT failed: Can't open mailbox : no such mailbox;
  nested exception is:
gnu.inet.imap.IMAPException: SELECT failed: Can't open mailbox : no such mailbox
        at gnu.mail.providers.imap.IMAPFolder.open(IMAPFolder.java:357)
at org.humannetwork.net.mail.IMAPFolderTest.testIMAPFolder (IMAPFolderTest.java:90)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
...
nested exception is:
gnu.inet.imap.IMAPException: SELECT failed: Can't open mailbox : no such mailbox
        at gnu.inet.imap.IMAPConnection.selectImpl(IMAPConnection.java:867)
        at gnu.inet.imap.IMAPConnection.select(IMAPConnection.java:821)
        at gnu.mail.providers.imap.IMAPFolder.open(IMAPFolder.java:338)
at org.humannetwork.net.mail.IMAPFolderTest.testIMAPFolder (IMAPFolderTest.java:90)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
...
Folder INBOX type is 0
Folder INBOX cannot contain subfolders.
Folder INBOX type is 0
Folder INBOX cannot contain subfolders.

Le 10 févr. 06 à 09:15, Chris Burdess a écrit :

Cedric Hyppolite wrote:
I am getting problems trying to list the subfolders of the default folder using GNU JavaMail IMAP provider v1.1. I guess that my problem comes from a bad usage of the API so the best would be to look into the code of a working application.

It may be a bug, do you have a test for it?
--
犬 Chris Burdess
  "They that can give up essential liberty to obtain a little safety
  deserve neither liberty nor safety." - Benjamin Franklin









reply via email to

[Prev in Thread] Current Thread [Next in Thread]