users@glassfish.java.net

Re: Setup of Glassfish Email to use remote server and Port

From: <glassfish_at_javadesktop.org>
Date: Mon, 24 Mar 2008 09:16:44 PST

Greetings:

   Thanks for your reply, but it does not help with my particular problem.

   First, your setup is very different from mine. I am not, for example, using Spring anywhere. This is a pure Glassfish setup.

   Second: the failure that I am getting is very different from yours. While I, too, am setting up a Java mail Session on the console, and specifying the email host, default user, and default return address, the Glassfish container is not going to the host I am specifying.

The precise failure I am getting is:

WARNING: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
  nested exception is:
        java.net.ConnectException: Connection refused
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
        at javax.mail.Service.connect(Service.java:288)
        at javax.mail.Service.connect(Service.java:169)
        at javax.mail.Service.connect(Service.java:118)
        at javax.mail.Transport.send0(Transport.java:188)
        at javax.mail.Transport.send(Transport.java:118)
        at factor3.web.bbase.gui.query.MailBean.sendBorrowRequest(MailBean.java:91)
        at factor3.web.bbase.gui.query.BorrowPanel.initiateBorrowing(BorrowPanel.java:138)
        at factor3.web.bbase.gui.query.BorrowPanel.actionPerformed(BorrowPanel.java:186)
        at thinwire.ui.EventListenerImpl.fireEvent(EventListenerImpl.java:314)
        at thinwire.ui.EventListenerImpl.fireAction(EventListenerImpl.java:246)
        at thinwire.ui.AbstractComponent.fireAction(AbstractComponent.java:159)
        at thinwire.render.web.ComponentRenderer.componentChange(ComponentRenderer.java:351)
        at thinwire.render.web.EventProcessor.processUserActionEvent(EventProcessor.java:132)
        at thinwire.render.web.EventProcessor.run(EventProcessor.java:88)
Caused by: java.net.ConnectException: Connection refused
        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:430)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.enterprise.server.ss.provider.ASPlainSocketImpl$2.run(ASPlainSocketImpl.java:419)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.enterprise.server.ss.provider.ASPlainSocketImpl._invoke(ASPlainSocketImpl.java:416)
        at com.sun.enterprise.server.ss.provider.ASPlainSocketImpl.connect(ASPlainSocketImpl.java:288)
        at com.sun.enterprise.server.ss.provider.ASClientSocketImpl.connect(ASClientSocketImpl.java:267)
        at java.net.Socket.connect(Socket.java:516)
        at java.net.Socket.connect(Socket.java:466)
        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
        ... 15 more

   The problem is: (a) for some reason Glassfish thinks the SMTP server is on Localhost -- when it is not and (b) it thinks it needs to use Port 25, which it does not.

   I need to know how to set it so that it goes to another machine to access the SMTP server and I also need to know how to make it use a specified port (other than Port 25). I also need to know how to set the server to send the SMTP server the proper username and password so that the email can be sent.

   Could you or someone please give an example of how to do these things??? Or am I going to need to switch Application Servers???
[Message sent by forum member 'factor3' (factor3)]

http://forums.java.net/jive/thread.jspa?messageID=265513