This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Trying to send e-mail using JavaMail, JBoss 5, and JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Trying to send e-mail using JavaMail, JBoss 5, and JNDI" Watch "Trying to send e-mail using JavaMail, JBoss 5, and JNDI" New topic
Author

Trying to send e-mail using JavaMail, JBoss 5, and JNDI

Michael K. Wilson
Ranch Hand

Joined: Apr 23, 2008
Posts: 45
Hello there,

Am using JBoss 5.1.0GA and JDK 1.5.0_19 on OS X Leopard.

Created a working SendMailServlet.

Have now decided to refactor it into two separate classes (extract out JavaMail code to a separate class and create a ServletController).

Am also trying to use JNDI to access the connection properties in the mail-service.xml configuration file residing in JBoss.

The Mailer class contains the reusable functionality needed to send an e-mail:



The MailController class serves as a standard Java Servlet which invokes the Mailer.class's sendMsg() method:



Have the mail configuration set under $JBOSS_HOME/server/default/deploy/mail-service.xml:



web.xml (Deployment Descriptor):



This is what is outputted when I start JBOSS and click point my browser to:

https://localhost:8443/myapp/sendmail



Why am I getting this java.net.ConnectException: Connection refused exception?

Happy programming,

Mike
Michael K. Wilson
Ranch Hand

Joined: Apr 23, 2008
Posts: 45
I fixed it! It works now!

Solution: Replace the mail.jar file on JBoss with the newest one from Sun and edit the mail configuration file to reflect port 465.

The JavaMail 1.4ea jar is what comes bundled with JBoss 5.1.0.GA inside:

$JBOSS_HOME/common/lib

Replaced it with 1.4.2 and then changed some of the xml config parameters around.

Debug output:



$JBOSS_HOME/server/default/deploy/mail-service.xml:



Please close this topic...

Happy programming,

Mike
 
Consider Paul's rocket mass heater.
 
subject: Trying to send e-mail using JavaMail, JBoss 5, and JNDI