0

I am trying to use apche-commons-email API for sending an email, in my java web application. I have configured the jboss5 mail-service.xml to send emails from Gmail id. But I am getting the error

org.jboss.resteasy.spi.UnhandledException: java.lang.ClassCastException: 
                 javax.mail.Session cannot be cast to javax.mail.Session

when executing the line

Session mailSession = (Session) ictx.lookup("java:/Mail");

Please help.

Mallikarjuna Reddy
  • 1,212
  • 2
  • 20
  • 33
aquero
  • 843
  • 4
  • 13
  • 30

1 Answers1

0

I can only see this as a custom class loader loading a javax.mail.Session class along with the original javax.mail.Session object !

But when attempting to cast an object of the first class to an instance of the second, an exception occurs because both objects don't match (i.e. method names, member variables..etc)

Check this answer and other answers for the same question.

Community
  • 1
  • 1
Muhammad Gelbana
  • 3,890
  • 3
  • 43
  • 81