NoSuchProviderException: smtp with log4j SMTP appender

Posted by user1016403 on Stack Overflow See other posts from Stack Overflow or by user1016403
Published on 2012-06-11T10:35:47Z Indexed on 2012/06/11 10:40 UTC
Read the original article Hit count: 536

Filed under:
|
|
|
|

I am using log4j to send an email when there is an exception. below is my log4j properties file configuration.

log4j.rootLogger=WARN, R, email
log4j.appender.R=org.apache.log4j.ConsoleAppender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{HH:mm:ss} %-5p [%c{1}]: %m%n
log4j.appender.email=org.apache.log4j.net.SMTPAppender
log4j.appender.email.BufferSize=10
log4j.appender.email.SMTPHost=myhost.com
[email protected]
[email protected]
log4j.appender.email.Subject=Error
log4j.appender.email.layout=org.apache.log4j.PatternLayout

mine is maven project i have added dependencies for mail.jar, activation.jar and smtp.jar. But on application server startup itself i get below error:

[ERROR] log4j:ERROR Error occured while sending e-mail notification.
[ERROR] javax.mail.NoSuchProviderException: smtp
[ERROR]     at javax.mail.Session.getService(Session.java:782)
[ERROR]     at javax.mail.Session.getTransport(Session.java:708)
[ERROR]     at javax.mail.Session.getTransport(Session.java:651)
[ERROR]     at javax.mail.Session.getTransport(Session.java:631)
[ERROR]     at javax.mail.Session.getTransport(Session.java:686)
[ERROR]     at javax.mail.Transport.send0(Transport.java:166)

Am i missing any thing here? What is the root cause of the error? is it because of incorrect SMTP host name? or is it because of any missing/conflicting dependencies?

© Stack Overflow or respective owner

Related posts about java

Related posts about log4j