0

我正在尝试apche-commons-email在我的 java Web 应用程序中使用 API 发送电子邮件。我已将其配置为jboss5 mail-service.xmlGmailid 发送电子邮件。但我得到了错误

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

执行该行时

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

请帮忙。

4

1 回答 1

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.

于 2013-03-21T00:34:36.760 回答