Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-14768

NPE when trying to send a mail with a not existing template

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 8.4
    • Fix Version/s: 9.9
    • Component/s: Mail
    • Labels:
      None
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      Example usage (make sure the template doesn't exist):

        #set ($templateParameters = {'type' : 'SendAll', 'language' : $xcontext.language })
        #set ($templateReference = $services.model.createDocumentReference('', 'Admin', 'MailTemplate'))
        #set ($parameters = {'hint' : 'template', 'parameters' : $templateParameters, 'source' : $templateReference })
      
        #set ($groupReference = $services.model.createDocumentReference('', 'XWiki', 'XWikiAllGroup'))
        #set ($source = {'groups' : [$groupReference]})
      
        #set ($messages = $services.mailsender.createMessages('usersandgroups', $source, $parameters))
      
        #set ($mailResult = $services.mailsender.send($messages, 'database'))
      

      Result:

      2017-10-06 12:23:09,186 [Mail Prepare Thread] ERROR o.x.m.i.DatabaseMailListener   - Failure during preparation phase of thread [f7e754d7-ab68-4c58-842c-12b5a81f549a] 
      java.lang.NullPointerException: null
      	at org.xwiki.mail.internal.factory.template.DefaultMailTemplateManager.getMailObjectsCount(DefaultMailTemplateManager.java:173)
      	at org.xwiki.mail.internal.factory.template.DefaultMailTemplateManager.getObjectMailNumber(DefaultMailTemplateManager.java:144)
      	at org.xwiki.mail.internal.factory.template.DefaultMailTemplateManager.evaluate(DefaultMailTemplateManager.java:94)
      	at org.xwiki.mail.internal.factory.template.AbstractTemplateMimeMessageFactory.createMessage(AbstractTemplateMimeMessageFactory.java:93)
      	at org.xwiki.mail.internal.factory.template.AbstractTemplateMimeMessageFactory.createMessage(AbstractTemplateMimeMessageFactory.java:45)
      	at org.xwiki.mail.internal.factory.usersandgroups.UsersAndGroupsMimeMessageIterator.next(UsersAndGroupsMimeMessageIterator.java:93)
      	at org.xwiki.mail.internal.factory.usersandgroups.UsersAndGroupsMimeMessageIterator.next(UsersAndGroupsMimeMessageIterator.java:43)
      	at org.xwiki.mail.internal.thread.PrepareMailRunnable.prepareMail(PrepareMailRunnable.java:122)
      	at org.xwiki.mail.internal.thread.PrepareMailRunnable.run(PrepareMailRunnable.java:78)
      	at java.lang.Thread.run(Thread.java:748)
      

        Attachments

          Activity

            People

            • Assignee:
              vmassol Vincent Massol
              Reporter:
              vmassol Vincent Massol
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: