java.net.SocketException:使用SMTP破坏管道

时间:2015-07-09 07:57:49

标签: java jboss smtp ejb javamail

当我的应用程序尝试发送电子邮件时,我的行为很奇怪。

20:59:08,926 ERROR [release.com.mycompany.mail.GenericMail] (EJB default - 5) [MY_EJB INBOUND] Sending message failed!: javax.mail.MessagingException: Can't send command to SMTP host;
  nested exception is:
    java.net.SocketException: Broken pipe
    at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2106) [mail-1.4.4-redhat-2.jar:1.4.4-redhat-2]
    at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2093) [mail-1.4.4-redhat-2.jar:1.4.4-redhat-2]
    at com.sun.mail.smtp.SMTPTransport.close(SMTPTransport.java:1184) [mail-1.4.4-redhat-2.jar:1.4.4-redhat-2]
    at javax.mail.Transport.send0(Transport.java:197) [mail-1.4.4-redhat-2.jar:1.4.4-redhat-2]
    at javax.mail.Transport.send(Transport.java:124) [mail-1.4.4-redhat-2.jar:1.4.4-redhat-2]
    at com.mycompany.MailUtils.sendMail(MailUtils.java:258) [classes:]

在此异常之前,抛出了一些超时异常:

    20:57:50,291 ERROR [org.jboss.as.ejb3] (EJB default - 9) [ ] JBAS014122: Error during
retrying timeout for timer: [id=6be904b5-c1ef-4f0e-a277-d4c9f93e21b3 timedObjectId=SOME_EJB 
auto-timer?:false persistent?:false timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@99fdab1 initialExpiration=/* date */ 00:00:00 UTC 2015 intervalDuration(in milli sec)=0 nextExpiration=/* other date */ 21:00:00 UTC 2015 
timerState=RETRY_TIMEOUT: javax.ejb.EJBTransactionRolledbackException: JBAS014373: 
EJB 3.1 PFD2 4.8.5.5.1 concurrent access timeout on org.jboss.invocation.InterceptorContext$Invocation@66668127 - could not obtain lock within 5000MILLISECONDS

说实话,我不知道发生了什么。我有5个小时的这种例外。 我想知道发生了什么,并且能够在将来避免例外。

更新1

SOME_EJB是一个与timerService一起使用的ejb。每3分钟运行一次,满足条件时发送电子邮件。

我唯一的想法是存在一些网络/数据库问题,导致单个任务执行花费超过3分钟。

MailUtils@Stateless ejb

1 个答案:

答案 0 :(得分:0)

邮件是否已发送?

看起来JavaMail正在关闭发生异常时与邮件服务器的连接。如果先前的错误导致服务器立即断开连接,则在关闭连接之前尝试发送SMTP BYE命令时,JavaMail可能会收到此异常。

启用JavaMail Session debugging以查看在发生此异常之前服务器可能报告的错误。