Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative for apache commons-email and Jakarta

We've upgraded our application to Spring6/Tomcat10 (that implies migration from Java EE to Jakarta) and could not find jakarta compatible alternative for apache commons-email library?!

We seem to have decent amount of custom code that uses commons-email. Have anyone else run into this issue before? What our options are?

After performing the initial research I can think of the following options (and to be honest I don't like neither one of them :-():

  1. Refactor our code to use jakarta.mail where commons-email library is used? (Seem to be a significant effort).
  2. Fork source code of the commons-email library and migrate it to jakarta ourselves? (Have anyone taken this route? If it's that straight-forward wondering why maintainer of the commons-email project have not done that already?)
  3. We tried to keep both javax-mail and jakarta-mail libraries in the classpath, and keep using commons-email in the places where it's used and it works most of the time, but sporadically throws:

java.lang.ClassCastException: class com.sun.mail.handlers.multipart_mixed cannot be cast to class jakarta.activation.DataContentHandler (com.sun.mail.handlers.multipart_mixed and jakarta.activation.DataContentHandler are in unnamed module of loader 'app')

Is there anything else we can do? Any help with be greatly appreciated!

like image 832
ROMAN Avatar asked Sep 05 '25 08:09

ROMAN


1 Answers

commons-email 2.0.0 which will be compatible with the jakarta namespace will be available soon (I'm writing this answer on 2024-01-15) as you can see in this Jira ticket : https://issues.apache.org/jira/browse/EMAIL-203

like image 91
Olivier Masseau Avatar answered Sep 08 '25 23:09

Olivier Masseau