A team, of which I am a member, is in the process of moving several applications from Websphere App server to Tomcat. I've had an email function in my application for a long while with no trouble. Now, I have an intermittent problem occurring when I try to use JavaMail to send email. It works sometimes and not others. The exception says something about connecting to the localhost, but I set mail.smtp.host to a remote host.
It appears to be related to system resources in some way because the problem tends to arise after the server has been running for a few hours. I increased the heap size and the MaxPermSize, but there doesn't really seem to be a shortage in memory according to Lambda Probe. It still happens on and off. There are also a few other web apps running on this Tomcat instance as well. Any ideas on how to make this more stable would be appreciated. Are there Tomcat specific things I need to do for JavaMail? Thanks so much for any help, Matt Below are the stack trace and a snippet of the JavaMail code. Properties props = System.getProperties(); props.put("mail.smtp.host", this.smtpServer); Session session = Session.getDefaultInstance(props, null); Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(this.from)); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(this.to)); msg.setSubject(this.subject); msg.setText(this.body); msg.setSentDate(new Date()); Transport.send(msg); ERROR 2007-01-26 11:14:37,913 (ComplicatedEmail.java:send:125) - javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370) at javax.mail.Service.connect(Service.java:275) at javax.mail.Service.connect(Service.java:156) at javax.mail.Service.connect(Service.java:105) at javax.mail.Transport.send0(Transport.java:168) at javax.mail.Transport.send(Transport.java:98) at com.nuhorizons.rosettanet.www.ComplicatedEmail.send(ComplicatedEmail.java:11 2) at com.nuhorizons.rosettanet.util.AlertEmailUtil.sendEmail(AlertEmailUtil.java: 265) at com.nuhorizons.rosettanet.util.AlertEmailUtil.sendDesignEmail(AlertEmailUtil .java:242) at com.nuhorizons.rosettanet.util.AlertEmailUtil.send5C2SentSuccessfully(AlertE mailUtil.java:148) at com.nuhorizons.rosettanet.controller.transmit.remote.RemoteRequestRegistrati onTransmitter.sendSuccessAlert(RemoteRequestRegistrationTransmitter.java:150 ) at com.nuhorizons.rosettanet.controller.transmit.remote.RemoteMessageTransmitte r.doPost(RemoteMessageTransmitter.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126 ) at org.jstripe.tomcat.probe.Tomcat55AgentValve.invoke(Tomcat55AgentValve.java:2 0) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105 ) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processC onnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav a:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWo rkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav a:684) at java.lang.Thread.run(Thread.java:595) Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:507) at java.net.Socket.connect(Socket.java:457) at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232) at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189) at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250) ... 30 more The information contained in this e-mail is legally privileged and confidential information intended only for use by the individual or entity named above. If the reader of this e-mail is not the intended recipient, you are hereby notified that any dissemination or distribution hereof is prohibited. If you have received this e-mail in error, please delete the material from your computer and immediately notify us at 631-396-5000. Thank you. --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]