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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 9.9
    • 8.4
    • Mail
    • None
    • Unknown
    • N/A
    • N/A

    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

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: