Monday, January 05, 2009

javax.mail.NoSuchProviderException: smtp

I've recently been trialling the Amazon's EC2 cloud computing service, trying to get an old Appfuse 1.9 application up and running. The EC2 public image I started with was based on a pretty naked Fedora 8. After installing Apache, Tomcat and a few other bits I deployed my old war and everything worked fine.

Fine that is except a quartz scheduled job that emails out a report every day. It kept failing with -


Unable to send message - org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.NoSuchProviderException: smtp


Fedora comes with a non Sun java jdk as standard so first thing I did was replace that with the Sun java. No luck. Tried and checked the localhost mailserver - all fine. Probably tried another few dozen things until I found some old posting about making sure you don't have more than one activation.jar's on the classpath. My project included an activation.jar, so I removed that from the WEB-INF/lib. Even worse.

Eventually tracked it down to a link in /var/lib/tomcat5/common/lib linking to a copy of activation.jar in /usr/share/java. Removed the link, restarted Tomcat and everything was fine.

Normally I'd probably try and track down the issue a bit further rather than just go for the quick fix, but its a test and it works. The EC2 image won't go into production.

No comments: