This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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:
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?