0

Please refer below code snippet in 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"/>

Getting the below error while deploying application in liberty server version 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.

I have already removed the mail jar in other places and kept only in ear/web-inf/lib folder alone.but even getting the same error. Can anyone tel how to configure mail session in Liberty . Liberty 8.5.5.7 version not supporting java Mail 1.5 feature.

Note : My Application already running successfully in Tomcat /WAS .

Vasanth
  • 474
  • 2
  • 9
  • 31
  • 1
    Hmm, according to this IBM KnowledgeCenter topic https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/rwlp_prog_model_support.html, JavaMail 1.5 support was added in Liberty 8.5.5.6 . Have you tried simply configuring the java mail feature using this KC topic: https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.wlp.iseries.doc/ae/twlp_admin_javamail.html – F Rowe Nov 13 '17 at 14:15
  • Thanks for your information.8.5.5.7 version not supporting javaMail 1.5 feature.So we cannot enable that feature in server.xml – Vasanth Nov 15 '17 at 08:05
  • You've said that three times now, but it's still not true. Look at the link I posted above. – F Rowe Nov 15 '17 at 13:35

1 Answers1

0

You should use <feature>javaMail-1.5</feature> in your server.xml and then configure session something like this:

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

In application you request it like this:

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

Check the following resources:

Gas
  • 17,601
  • 4
  • 46
  • 93
  • Thanks .8.5.5.7 version not supporting the javaMail 1.5 feature – Vasanth Nov 15 '17 at 08:07
  • This is NOT true. It is supported since 8.5.5.6. - https://developer.ibm.com/answers/questions/195785/liberty-85-and-javamail/ . So for sure it is supported in 8.5.5.7. Probably you dont have that feature installed if you just downloaded the 'webprofile' version.You may need to use `installUtility javaMail-1.5` to add it to your runtime. – Gas Nov 15 '17 at 10:59