File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes javax.mail.NoSuchProviderException: smtp when sending emails using a javax.swing.Timer class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "javax.mail.NoSuchProviderException: smtp when sending emails using a javax.swing.Timer class" Watch "javax.mail.NoSuchProviderException: smtp when sending emails using a javax.swing.Timer class" New topic
Author

javax.mail.NoSuchProviderException: smtp when sending emails using a javax.swing.Timer class

David Squire
Greenhorn

Joined: Sep 23, 2009
Posts: 5
I have a JSF web application that uses a javax.swing.Timer class to check for accounts that are going to be expiring soon. If there are accounts expiring, it will send the user an email. The Timer task is started by a context listener and runs once a day.

When I first deploy the application it works just fine for weeks. But then after a while it starts to fail with:

javax.mail.NoSuchProviderException: smtp

If I reboot the server it starts to work again, but only for a few days before it starts to fail again.

I am using Tomcat and have placed the mail.jar and the smtp.jar into Tomcat's lib folder as well as including them in my application (using NetBeans).

The class that contains the code that actually sends the email is also used when a user clicks on the "Forgot Password" link, and clicking on the "Forgot Password" link never causes this exception (even when the Timer task is failing with the exception).

It feels like somehow the Timer class forgets the smtp library after a while. Is that possible? If so, is there a way that I can force it to know how to load that library before I try to send email?

Is there some other way that I should be sending out these regular emails?

Thank you for any input you may have!

Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.mail.NoSuchProviderException: smtp when sending emails using a javax.swing.Timer class