掲示板

LinkageError when sending email from Liferay7 portlet

thumbnail
7年前 に Clint Wilde によって更新されました。

LinkageError when sending email from Liferay7 portlet

Junior Member 投稿: 39 参加年月日: 13/03/05 最新の投稿
Hello,

I am converting a legacy portlet to a Liferay 7 portlet and ran across an issue when calling Liferay's com.liferay.mail.kernel.service.MailServiceUtil.sendEmail() function.

Here is my code:
MailMessage mailMessage = new MailMessage(new InternetAddress(fromAddress), subject, messageBody, true);
mailMessage.setHTMLFormat(true);

mailMessage.setTo(new InternetAddress(toAddress));
MailServiceUtil.sendEmail(mailMessage);


Error Message I'm getting:
java.lang.LinkageError: loader constraint violation: when resolving method 
 "com.liferay.mail.kernel.model.MailMessage.<init>(Ljavax/mail/internet/InternetAddress;Ljava/lang/String;Ljava/lang/String;Z)V" the class loader 
 (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) of the current class, com/xtivia/photolibrary/portlet/PhotoLibPortlet, and the class loader 
 (instance of java/net/URLClassLoader) for the method's defining class, com/liferay/mail/kernel/model/MailMessage, have different Class objects for the type 
 javax/mail/internet/InternetAddress used in the signature</init>


Thanks in advance for your help.
thumbnail
7年前 に Jack Bakker によって更新されました。

RE: LinkageError when sending email from Liferay7 portlet

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
I just did a portlet over Liferay 7 GA3 with a MailMessage that works. Below is my build.gradle. Not sure if this helps. As an OSGi nube, when I get OSGi errors I usually have no idea what they mean.


dependencies {
	compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
	compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
	compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
	compileOnly group: "javax.servlet", name: "servlet-api", version: "2.5"
	compileOnly group: "jstl", name: "jstl", version: "1.2"
	compileOnly group: "org.osgi", name: "org.osgi.compendium", version: "5.0.0"
	compile 'javax.mail:mail:1.4.7'
	compile group: "ca.iable", name: "db.iable-api", version: "1.0.0"
}
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: LinkageError when sending email from Liferay7 portlet

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Yeah, Clint, I'm thinking you have included javax.mail jar in your module as a dependency but it's not working well with the global mail.jar from lib/ext.