JavaMail:在某些机器上连接并在其他一些机器上连接错误

时间:2015-06-17 10:53:56

标签: java javamail

我正在使用JavaMail从gmail帐户读取java电子邮件。代码在我的Windows 7机器上工作得很好。但是,在Windows 2k8计算机上运行后,相同的代码错误(下面提到的是错误)。代码绝对没有变化。 有人可以帮助了解这次失败的原因吗?

错误:

   javax.mail.MessagingException: Connection timed out: connect;
  nested exception is:
    java.net.ConnectException: Connection timed out: connect
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:618)
    at javax.mail.Service.connect(Service.java:291)
    at javax.mail.Service.connect(Service.java:172)
    at com.vmware.cmpaas.uiqe.util.EmailUtil.getActivationLink(EmailUtil.java:42)
    at Temp_Test.main(Temp_Test.java:17)
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
    at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:160)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:284)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:227)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:109)
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:585)
    ... 4 more
Exception in thread "main" java.lang.NullPointerException
    at Temp_Test.main(Temp_Test.java:18)

0 个答案:

没有答案