Reputation: 483
I am trying to send email using Javax in the spark env. When I try to build this code in IntelliJ it is building properly without any issues.
But when I bring this code to the server and try to run it I am getting the below error
java.lang.ClassNotFoundException: javax.mail.Message
Scala Code Snippet
val message = new MimeMessage(session)
message.setFrom("[email protected]")
//message.addRecipients(Message.RecipientType.TO, to_address)
message.addRecipients(javax.mail.Message.RecipientType.TO, "[email protected]")
I have tried by keeping javax.mail-1.5.6.jar as well as commons-email-1.5.jar in my class path in the server and still getting this error.
Spark Commands
spark-submit --master yarn --conf spark.driver.maxResultSize=0 --conf spark.driver.extraClassPath=/home/abc/commons-email-1.5.jar,/home/abc/activation-1.1.1.jar --conf spark.executor.extraClassPath=/home/abc/commons-email-1.5.jar,/home/abc/activation-1.1.1.jar --jars /home/abc/commons-email-1.5.jar --jars /home/abc/activation-1.1.1.jar --class com.abc.common.utils.UtilityMailer ./abc-xyz.jar
spark-submit --master yarn --conf spark.driver.maxResultSize=0 --conf spark.driver.extraClassPath=/home/abc/javax.mail-1.5.6.jar,/home/abc/activation-1.1.1.jar --conf spark.executor.extraClassPath=/home/abc/javax.mail-1.5.6.jar,/home/abc/activation-1.1.1.jar --jars /home/abc/javax.mail-1.5.6.jar --jars /home/abc/activation-1.1.1.jar --class com.abc.common.utils.UtilityMailer ./abc-xyz.jar
Kindly Help!!!
Upvotes: 1
Views: 584
Reputation: 338785
I will take a guess… You are experiencing a clash of package names because:
Java EE uses javax.*
package naming. After Oracle Corp handed responsibility for Java EE to the Eclipse Foundation, they changed the package naming to jakarta.*
.
You can read more about this Jakarta transition in many places in the industry press, video lectures, and conference presentations.
To fix your problem, either:
import
statements from javax
to jakarta
.Both choices are valid. Most vendors will support their Java EE era products for years. But future improvements and innovations will happen mainly in the new generation of Jakarta EE product releases. So you’ll eventually want to migrate to Jakarta EE. But doing so is not urgent.
Upvotes: 2