Parallels Forums
> Plesk Products Discussion > Parallels Plesk Panel for Linux/Unix > Plesk 8.6 for Linux > Plesk 8.6 for Linux Troubleshooting Issues  
Tomcat throws " javax.mail.NoSuchProviderException: No provider for smtp"  
  

Tomcat throws " javax.mail.NoSuchProviderException: No provider for smtp"

Dec 9, 2008, 01:40 AM
#1  

flupke
Senior Member


Join: Feb 2007
Posts: 246
Tomcat throws " javax.mail.NoSuchProviderException: No provider for smtp"
Hello,

customer tries to send email over Tomcat, no luck up to now, Tomcat throws an exception 'no provider for SMTP'. "Transport transport = mailSession.getTransport("smtp");" causes the exceptions. It is an internal Tomcat issues (path, authorization to use smtp...) but not to Qmail.

Any Tomcat guru with advises?

Here the code and exception

implementation of sendMail method:
>
> ppublic static boolean sendMail( String mailSmtp, String mailFrom,
> String mailTo,
> String mailSubject, String mailMessage ) throws Exception
> {
> try {
> String host = "DOMAIN";
> String user = "usrer";
> String pass = "xxxx";
> boolean sessionDebug = true;
>
> Properties properties = new Properties();
> properties.put( "mail.smtp.host", mailSmtp );
> properties.put("mail.transport.protocol", "smtp");
> properties.put( "mail.from", mailFrom );
> properties.put("mail.smtp.auth", "true");
>
> Session mailSession = Session.getInstance( properties, null );
> mailSession.setDebug(sessionDebug);
>
> InternetAddress[] mailAddress = { new InternetAddress( mailTo ) };
> SMTPMessage message = new SMTPMessage( mailSession );
> message.setRecipients( Message.RecipientType.TO, mailAddress );
> message.setFrom( new InternetAddress( mailFrom ) );
> message.setSubject( mailSubject );
> message.setContent( mailMessage, "text/html" );
> message.setSentDate( new Date() );
>
> Transport transport = mailSession.getTransport("smtp");
> transport.addConnectionListener( new ConnectionHandler() );
> transport.addTransportListener( new TransportHandler() );
> transport.connect(host, user, pass);
> transport.sendMessage( message, mailAddress );
> transport.close();
> } catch ( Exception ex ) {
> System.out.println("SendMail Exception " + ex.getMessage());
> return false;
> }
>
> return true;
> }
>
>
>
> --------- exception -------
>
> The statement " Transport transport =
> mailSession.getTransport("smtp");" causes the excpetion:
>
> javax.mail.NoSuchProviderException: No provider for smtp
> at javax.mail.Session.getProvider(Session.java:289)
> at javax.mail.Session.getStore(Session.java:363)
> at SimpleClient.main(SimpleClient.java:118)
Dec 24, 2008, 11:02 AM
#2  

geneo
Junior Member


Join: Dec 2008
Posts: 2
Hi,
I am having a similar problem for a customer of mine.
I was wondering if you were able to solve the problem?
Dec 26, 2008, 03:32 PM
#3  

gorilych
Member


Join: Aug 2006
Posts: 76
JavaMail libraries has to be installed according to instructions
from tomcat documentation:
http://tomcat.apache.org/tomcat-5.5-...ces-howto.html

In short it is needed to copy mail.jar and activation.jar to
/usr/share/tomcat5/common/lib/

Of course you will need to restart tomcat after that.
Dec 28, 2008, 02:01 AM
#4  

dolivia
Junior Member


Join: Dec 2008
Posts: 1
Geneo,
We use NGASI AppServer Manager for our Java Hosting.
One of the features is configuring the Mail object for applications
to access. So you don't have to become a java export.
Their website is http://www.ngasi.com. It works with Plesk,
which we use for general web site management.
Jan 6, 2009, 05:13 PM
#5  

geneo
Junior Member


Join: Dec 2008
Posts: 2
Yeah. Thanks for the info. ngasi was exactly the solution I was looking for!
Wow. It also has the ability to configure each customer's application datasource as well virtual hosting.

Thanks again for the link.


Thread tools Display modes
Linear Mode