Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Michael K. Wilson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic