使用Liberty服务器迁移 - 如何在Liberty中配置邮件会话

时间:2017-11-13 12:37:06

标签: spring javamail websphere-liberty

请参阅liberty server.xml中的以下代码片段。

<library id="objectFactoryLib">
      <fileset dir="" includes="naming-factory-5.5.15.jar"/>
     <fileset dir="" includes="javax.mail-1.5.5.jar"/>
 </library>

 <jndiObjectFactory  className="org.apache.naming.factory.MailSessionFactory" id="mailSessionFactory" libraryRef="objectFactoryLib" objectClassName="javax.mail.Session"/>

在自由服务器版本8.5.5.7中部署应用程序时出现以下错误。

Cannot convert value of type [javax.mail.Session] to required type [javax.mail.Session] for property 'session': no matching editors or conversion strategy found.

我已经在其他地方删除了邮件jar并且只保留在ear / web-inf / lib文件夹中。但即使得到相同的错误。 任何人都可以告诉如何在Liberty中配置邮件会话。 Liberty 8.5.5.7版本不支持java Mail 1.5功能。

注意:我的应用程序已在Tomcat / WAS中成功运行。

1 个答案:

答案 0 :(得分:0)

您应该在<feature>javaMail-1.5</feature>中使用server.xml,然后将会话配置为:

<mailSession
   description="Mail session for testing"
   from="Liberty2@itso.ibm.com"
   host="mailHost"
   jndiName="mail/itsoMailSession"
   mailSessionID="itsoMailSession"
   user="validUser@account.com"
   password="password"/>

在申请表中,您可以这样请求:

@Resource(lookup="mail/itsoMailSession")
Session mailSession;

检查以下资源:

相关问题