java.lang.ClassCastException:com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart无法强制转换

时间:2019-01-07 07:14:30

标签: java mime classcastexception

当我尝试发送消息时,我遇到了类强制转换异常。

我觉得不是拿javax.mail.internet,而是拿jdk一罐。

java.lang.ClassCastException: com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart cannot be cast to javax.mail.internet.MimeMultipart

MimeMessage mimeMessage = (MimeMessage) content;
              ContentType multiContentType = new ContentType(mimeMessage
                                                                 .getContentType());

   final MimeMultipart mimeMultipart = (MimeMultipart) mimeMessage.getContent(); // line I am getting ClassCast exception.

我试图通过这种方式更改代码:

final javax.mail.internet.MimeMultipart mimeMultipart = (javax.mail.internet.MimeMultipart) mimeMessage.getContent();

但是它不起作用。

0 个答案:

没有答案