Unable to resolve Exception thrown by jira-jql-function plugin : Unable to run plugin code because of 'java.lang.ClassCastException - com.sun.mail.handlers.text_plain cannot be cast to javax.activation.DataContentHandler

I have followed the https://developer.atlassian.com/server/jira/platform/adding-a-jql-function-to-jira/ tutorial to create a JQL function and now I am trying to send an attachment in an email .
I am using javax.mail for that . But while running the code , I am getting an exception : Unable to run plugin code because of ‘java.lang.ClassCastException - com.sun.mail.handlers.text_plain cannot be cast to javax.activation.DataContentHandler’.

Dependency added in my pom.xml :

com.sun.mail
javax.mail
1.6.2