我正在尝试从同时使用 MailEngine 和 MailServiceUtil 的钩子发送电子邮件,但我还不能发送它。我的代码如下:
InternetAddress from=null;
InternetAddress to=null;
try {
from = new InternetAddress("test@test.com", "Admin admin");
to = new InternetAddress(newUser.getEmailAddress(), newUser.getFirstName());
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MailMessage mailMessage = new MailMessage();
mailMessage.setFrom(from);
mailMessage.setTo(to);
mailMessage.setBody(body);
mailMessage.setSubject(subject);
MailServiceUtil.sendEmail(mailMessage);
在此我收到以下错误,
java.lang.LinkageError: loader constraint violation: when resolving method "com.liferay.portal.kernel.mail.MailMessage.setFrom(Ljavax/mail/internet/InternetAddress;)V" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/lftechnology/sbworkbench/hooks/createaccount/CustomCreateAccountAction, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, com/liferay/portal/kernel/mail/MailMessage, have different Class objects for the type javax/mail/internet/InternetAddress used in the signature
我在 liferay 安装中找到了一个 mail.jar 文件,但我无法使用它。我尝试使用 artifactid com.sun 在我的 pom 文件中导入 javax.mail,但仍然出现此错误。这里有人知道问题是什么吗?
谢谢