Getting the following exception while trying to connect to the store.
2:56:26,020 ERROR [STDERR] javax.mail.MessagingException;
nested exception is:
java.io.IOException
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
12:56:26,021 ERROR [STDERR] at javax.mail.Service.connect(Service.java:275)
12:56:26,021 ERROR [STDERR] at javax.mail.Service.connect(Service.java:156)
12:56:26,021 ERROR [STDERR] at com.invient.tickets.emailprocessor.EmailProcessorUtil.connect(Unknown Source)
12:56:26,021 ERROR [STDERR] at com.invient.tickets.emailprocessor.EmailProcessorThread.connect(Unknown Source)
12:56:26,021 ERROR [STDERR] at com.invient.tickets.emailprocessor.EmailProcessorThread.run(Unknown Source)
12:56:26,021 ERROR [STDERR] Caused by: java.io.IOException
12:56:26,021 ERROR [STDERR] at com.sun.mail.iap.ResponseInputStream.read0(ResponseInputStream.java:99)
12:56:26,021 ERROR [STDERR] at com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:67)
12:56:26,021 ERROR [STDERR] at com.sun.mail.iap.Response.<init>(Response.java:83)
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:48)
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:122)
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:230)
12:56:26,021 ERROR [STDERR] at com.sun.mail.iap.Protocol.<init>(Protocol.java:91)
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87)
12:56:26,022 ERROR [STDERR] at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446)
12:56:26,022 ERROR [STDERR] ... 5 more
The following is my Properties list
prop.put("mail.imap.host", "imap.gmail.com");
prop.put("mail.imap.user", "abc");
prop.put("mail.imap.ssl.enable", "true");
prop.put("mail.debug", "false");
prop.put("mail.imap.port", "993") ;
prop.put("mail.debug.quote", "false") ;
prop.put("mail.store.protocol", "imap") ;
When I do the following
Session session = Session.getInstance(prop);
Store store = session.getStore();
store.connect("imap.gmail.com", "userName", "passwd");
I get the above exception. When I tried the same code with a standalore program, it worked fine. I was able to connect. But when I put the code in to my JBoss, it throws the exception.
When I went into the source of mail.jar where it throwed exception, I could see that when it tries to read from the Socket it throws the exception.
Thanks in Advance.
With the following properties the connect works. Can anybody explain what was the problem with the earlier setup?
prop.put("mail.imap.host", "imap.gmail.com");
prop.put("mail.imap.user", "abc");
prop.put("mail.imap.ssl.enable", "true");
prop.put("mail.debug", "true");
prop.put("mail.imap.port", "993") ;
prop.put("mail.debug.quote", "false") ;
prop.put("mail.store.protocol", "imaps") ;
prop.put("mail.imap.socketFactory.class","javax.net.ssl.SSLSocketFactory");
prop.put("mail.imap.socketFactory.fallback", "false");