1 Reply Latest reply: Jan 29, 2013 10:44 PM by Bill Shannon-Oracle RSS

    What does an IOException nested inside a MessagingException mean on connect

    987944
      Greetings everyone,

      I'm trying to connect to an exchange server with IMAPS on port 443 (it's been configured this way on the other end) using the following code:

      . . .
                  props.setProperty("javax.net.ssl.trustStore", "C:/Program Files/Java/jdk1.6.0_30/jre/lib/security/cacerts");
                  props.setProperty("javax.net.ssl.trustStorePassword", "changeit");
                  props.setProperty("javax.net.ssl.trustStoreType", "jks");
                  props.setProperty("javax.net.debug", "ssl");
      
                  System.setProperties(props);
      
                  props = System.getProperties();
      
                  final Session session = Session.getInstance(props, null);
                  session.setDebug(debug);
                  com.sun.mail.imap.IMAPFolder inbox = null;
                  Store store = null;
      
                  store = session.getStore("imaps");
                  store.connect(host, 443, username, password);
                  inbox = (com.sun.mail.imap.IMAPFolder) store.getFolder("INBOX");
      . . .

      Judging from the fact that I get no certificate errors, I assume they are correctly loaded from the store location. However, I get the following trace once the code reaches the connect statement:
      [29/01/13 18:23:02:811 CST] 0000007d SystemOut     O DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
      [29/01/13 18:23:02:812 CST] 0000007d SystemOut     O DEBUG: mail.imap.fetchsize: 16384
      
      [29/01/13 18:18:42:814 CST] 0000007d SystemErr     R javax.mail.MessagingException;
      nested exception is:
      java.io.IOException
      [29/01/13 18:18:42:814 CST] 0000007d SystemErr     R    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
      [29/01/13 18:18:42:814 CST] 0000007d SystemErr     R    at javax.mail.Service.connect(Service.java:275)
      [29/01/13 18:18:42:814 CST] 0000007d SystemErr     R    at com.scots.utils.MailPoller$1.run(MailPoller.java:74)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at java.lang.Thread.run(Thread.java:738)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R Caused by: java.io.IOException
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at com.sun.mail.iap.ResponseInputStream.read0(ResponseInputStream.java:99)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:67)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at com.sun.mail.iap.Response.<init>(Response.java:83)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:48)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:122)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:230)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at com.sun.mail.iap.Protocol.<init>(Protocol.java:91)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87)
      [29/01/13 18:18:42:815 CST] 0000007d SystemErr     R    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446)
      [29/01/13 18:18:42:816 CST] 0000007d SystemErr     R    ... 3 more
      And nothing else! I've searched everywhere for the possible meanings or causes for an IOException thrown during the connect execution, but I've got nothing so far.

      Given that the stacktrace doesn't go any further and the only line of my own code referenced in it is the connect statement itself
      com.scots.utils.MailPoller$1.run(MailPoller.java:74)
      , I really don't have much to go on.

      The only thing that comes to mind that could be causing throuble is that I've put the mail polling mechanics inside another thread (a run method). Could that be causing trouble? Additionally, the host I'm using is not an IP address but a URL I'm expecting to be visible from my location. I can ping the URL and access it via browser just fine (it's an exchange server and I can see the owa service working from my browser) but I wonder if it could cause problems to use a host like this.

      Any ideas you could provide will be greatly appreciated!

      Thanks in advance.