<div dir="ltr"><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div>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).</div>
<div><br></div><div>This seems to be a ClassLoader issue, but I'm not well versed in ClassLoaders, especially with their use in glassfish, JavaMail, or logback.</div><div><br></div><div>In the ${GLASSFISH_HOME}/glassfish/domains/domain1/config directory, I have placed:</div>
<div><br></div><div>logback.xml (my logback config file)</div><div><br></div><div>As I read online somewhere (I forget where), I placed the following files in the ${GLASSFISH_HOME}/glassfish/lib/endorsed directory:</div><div>
<br></div><div>logback-core-1.1.2.jar</div><div>logback-classic-1.1.2.jar</div><div>jul-to-slf4j-1.7.7.jar (to redirect glassfish's built-in java.util.logging to logback)</div><div>slf4j-api-1.7.7.jar (the logging api used log to logback)</div>
<div>guava-16.0.1.jar (used by my custom logback logging code)</div><div>custom-logging.jar (my custom logback logging code)</div><div>javax.mail-1.5.0.jar</div><div><br></div><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div>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.</div><div>
<br></div><div>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.</div><div><br></div><div>Any help resolving this issue would be greatly appreciated.</div>
<div><br></div><div>Thanks.</div></div>