[logback-user] NoSuchProviderException for smtp when using JavaMail 1.5.x with logback 1.1.2 SMTPAppender in glassfish 4

Ross Goldberg ross.goldberg at gmail.com
Wed Apr 23 10:06:16 CEST 2014

I am attempting to use the SMTPAppender from logback 1.1.2 in glassfish 4
to send email alerts for all logged errors, whether they are logged by
glassfish itself, by its various components / modules / libraries, or by my
code in a deployed ear.

At different times, I tried using either JavaMail 1.5.0 or 1.5.1; 1.5.0
because glassfish 4 includes JavaMail 1.5.0 in its modules directory. and I
wanted to try to be consistent; and 1.5.1 because it is the current version
of JavaMail.

I have configured the SMTPAppender, but when it tries to log an error from
code deployed in my ear, I get a NoSuchProviderException for smtp when
logback SMTPAppenderBase calls Transport.send(MimeMessage).

This seems to be a ClassLoader issue, but I'm not well versed in
ClassLoaders, especially with their use in glassfish, JavaMail, or logback.

In the ${GLASSFISH_HOME}/glassfish/domains/domain1/config directory, I have

logback.xml (my logback config file)

As I read online somewhere (I forget where), I placed the following files
in the ${GLASSFISH_HOME}/glassfish/lib/endorsed directory:

jul-to-slf4j-1.7.7.jar (to redirect glassfish's built-in java.util.logging
to logback)
slf4j-api-1.7.7.jar (the logging api used log to logback)
guava-16.0.1.jar (used by my custom logback logging code)
custom-logging.jar (my custom logback logging code)

logback SMTPAppender configuration fails without including
javax.mail-1.5.0.jar in lib/endorsed, or, alternately, mailapi-1.5.0.jar.
Using javax.mail-api-1.5.0.jar instead results in numerous errors in
logback configuration, so that is not an option.

If I use mailapi-1.5.0.jar without smtp-1.5.0.jar instead of using
javax.mail-1.5.0.jar, SMTPAppenderBase throws a NoSuchProviderException
when attempting to email glassfish errors (these are not errors from my
ear, but errors from outside my ear).  If I use javax.mail-1.5.0.jar,
SMTPAppenderBase emails glassfish errors perfectly fine.

I have tried various permutations of included JavaMail & logback jars the
WEB-INF/lib directory in the war in my ear, but I keep getting
NoSuchProviderExceptions when attempting to email errors that where logged
by code from my ear.

The only other JavaMail-related jars that I've found are in the glassfish
modules directory; I cannot remove them since (from what I've heard) they
are an integral part of glassfish.

If I run a simple test java main method outside of glassfish, with the
aforementioned jars in the classpath, error emails are sent correctly,
without any exceptions.

Any help resolving this issue would be greatly appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20140423/8671ca8e/attachment.html>

More information about the Logback-user mailing list