bbottema/simple-java-mail

java.lang.ClassNotFoundException: net.markenwerk.utils.mail.dkim.DkimMessage

adamzr opened this issue · 13 comments

Getting this error:

java.lang.ClassNotFoundException: net.markenwerk.utils.mail.dkim.DkimMessage
 	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0-8u162]
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0-8u162]
 	at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[mikvah-1.0.5.jar:1.0.5]
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0-8u162]
	at org.simplejavamail.mailer.internal.mailsender.MailSender.sendMailClosure(MailSender.java:240) ~[simple-java-mail-5.0.0.jar!/:na]
 	at org.simplejavamail.mailer.internal.mailsender.MailSender.send(MailSender.java:211) ~[simple-java-mail-5.0.0.jar!/:na]
 	at org.simplejavamail.mailer.Mailer.sendMail(Mailer.java:239) ~[simple-java-mail-5.0.0.jar!/:na]
 	at org.simplejavamail.mailer.Mailer.sendMail(Mailer.java:230) ~[simple-java-mail-5.0.0.jar!/:na]
 	at com.myservice.EmailService.sendEmail(EmailService.java:70) ~[classes!/:1.0.5]

That means you are trying to use the DKIM functionality, but didn't include the DKIM library.

It was removed from the Simple Java Mail JAR in issue #120. To add this functionality, include the following dependency in your POM:

<dependency>
    <groupId>net.markenwerk</groupId>
    <artifactId>utils-mail-dkim</artifactId>
    <version>1.1.11</version>
</dependency>

I agree the documentation is incomplete on this, so I'm going to set that straight asap.

@bbottema I'm also getting this error, but without calling any DKIM-related functionality.

Could it be that there are still some hidden/implicit dependencies on utils-mail-dkim?

@vincent-dm, do you have a stacktrace?

Yes @bbottema :

                                  app.libs.smtp.core.Smtp/send-email             core.clj:   59
                               org.simplejavamail.mailer.Mailer.sendMail          Mailer.java:  230
                               org.simplejavamail.mailer.Mailer.sendMail          Mailer.java:  239
           org.simplejavamail.mailer.internal.mailsender.MailSender.send      MailSender.java:  211
org.simplejavamail.mailer.internal.mailsender.MailSender.sendMailClosure      MailSender.java:  240
                                         java.lang.ClassLoader.loadClass     ClassLoader.java:  357
                              sun.misc.Launcher$AppClassLoader.loadClass        Launcher.java:  338
                                         java.lang.ClassLoader.loadClass     ClassLoader.java:  424
                                       java.net.URLClassLoader.findClass  URLClassLoader.java:  381
java.lang.ClassNotFoundException: net.markenwerk.utils.mail.dkim.DkimMessage
  java.lang.NoClassDefFoundError: net/markenwerk/utils/mail/dkim/DkimMessage

(FYI: I'm using 5.0.0; my app is in Clojure)

This should be opened, as I also have it;

java.lang.ClassNotFoundException: net.markenwerk.utils.mail.dkim.DkimMessage
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1143)
	org.simplejavamail.mailer.internal.mailsender.MailSender.sendMailClosure(MailSender.java:240)
	org.simplejavamail.mailer.internal.mailsender.MailSender.send(MailSender.java:211)
	org.simplejavamail.mailer.Mailer.sendMail(Mailer.java:239)
	org.simplejavamail.mailer.Mailer.sendMail(Mailer.java:230)
	restapi.MailController.mail(MailController.java:29)

The code is just the simple builder example so I do not see why DKIM should be called at all.

Agreed, I will look into it

I'm not sure yet how to solve this. The class throwing the error has a dependency on DKIM, but only uses the Class when it is needed and available (otherwise customized error). It seems the Class loader is trying to load all classes eagerly.

Ok, I think I found a way to do this nicely. New version coming up soon.

@adamzr, @maartenst, @vincent-dm,

Please confirm the problem is solved with with 5.0.1-SNAPSHOT (you'll need to add the snapshot repo).

This fixed it for me, thanks for the quick response!

Solved!

Encountered the exact same issue, 5.0.1-SNAPSHOT solved the problem for me as well.

Released in 5.0.1. Thanks for the report!