13
votes

I am getting below mentioned error. I copied mail.jar, activation.jar, mailapi.jar, common-lang3.jar to /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext

java.lang.NoClassDefFoundError: javax/activation/DataHandler
    at org.apache.commons.mail.Email.createMimeMessage(Email.java:1832)
    at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1268)
    at org.apache.commons.mail.Email.send(Email.java:1436)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at RJavaTools.invokeMethod(RJavaTools.java:386)
Caused by: java.lang.ClassNotFoundException
    at RJavaClassLoader.findClass(RJavaClassLoader.java:383)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
    ... 8 more
NULL
Error: NoClassDefFoundError (Java): javax/activation/DataHandler
3

3 Answers

21
votes

One of the comments in the link Vince Fulco provided works in Ubuntu 18.04: https://github.com/rpremraj/mailR/issues/77#issuecomment-465741847

Specifically:

  1. Download the following .jar files:

  2. Find out the java-mailR folder: system.file("java", package = "mailR")

    • In my case: "/home/MY_USERNAME/R/x86_64-pc-linux-gnu-library/3.5/mailR/java"
  3. Copy the two .jar files into that folder

Just in case, I rebooted the computer before trying it.

2
votes

This a well discussed and so far unresolved issue on github. https://github.com/rpremraj/mailR/issues/77

2
votes

Check your authentication credentials for SMTP. This error comes as a result of failure of authentication details