Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javax.mail no longer working with java 11 and tomcat 8.5

I am using java 11.0.4 2019-07-16 LTS on Ubunutu 18 and Apache Tomcat 8.5.

I created a class for sending emails that imports

import javax.mail.*;
import javax.mail.internet.*;

Now, when I used java 8I did not have any problems with sending my emails. However, now it does not work instead I am getting a 500 error.

And having a look at my localhost.2019-08-20.log I can find the following stacktrace:

20-Aug-2019 17:13:14.961 SEVERE [http-nio-80-exec-96] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [mlc.servlets.DispatcherServlet] in context with path [] threw exception [Servlet execution threw an exception] with root cause
    java.lang.ClassNotFoundException: javax.activation.DataHandler
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1360)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1182)
        at mlc.Mailer.sendEMail(Mailer.java:35)
        ...and so on...

Doing some research I think the problem is that the module java.activation is not loaded.

However, I did not find any solution on the internet. I only found that java.activation has been removed from java 11. So, I guess I need something else.

So, my questions: What do I have to do that my webapp can - again - send emails using Tomcat 8.5?

Thanks

like image 891
toom Avatar asked Aug 20 '19 15:08

toom


People also ask

What is the replacement for javax activation package in Java 11?

JavaBeans Activation Framework (JAF) is possibly the alternative you are looking for to the existing package.


1 Answers

Include the latest version of javax.activation in your program.

like image 119
Bill Shannon Avatar answered Oct 11 '22 09:10

Bill Shannon