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

Error when looking for a previous mail status for message

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 8.3-milestone-1, 8.2.2
    • 8.2
    • Mail
    • Chrome 51
      Windows 10
      MySQL 5.7 / HSQLDB 2.3.3
      Java 8
    • Unknown
    • N/A
    • N/A

    Description

      1. Open a local clean instance of XE 8.2 with default DB.
      2. Configure your email server.
      3. Create a test page and add this code in Source mode (http://extensions.xwiki.org/xwiki/bin/view/Extension/Mail+Sender+API#HExample1:Sendasimpletextemail)

      {{velocity}}
      #set ($message = $services.mailsender.createMessage("localhost@xwiki.org", "john@doe.com", "subject"))
      #set ($discard = $message.addPart("text/plain", "text content"))
      #set ($mailResult = $services.mailsender.send([$message], 'database'))
      ## Check if the message was created properly and if we have permissions to send emails
      #if ($services.mailsender.lastError)
        {{error}}$exceptiontool.getStackTrace($services.mailsender.lastError){{/error}}
      #end
      ## Check if the mail we tried to send has failed to be sent
      ## XWiki < 7.1 use #set ($statuses = $mailResult.statusResult.getByState('FAILED'))
      #set ($statuses = $mailResult.statusResult.getAllErrors())
      #if ($statuses.hasNext())
        #set ($status = $statuses.next())
        {{error}}
          Error: $status.errorSummary ($status.state)
      
          $status.errorDescription
        {{/error}}
      #end
      {{/velocity}}
      

      4. Add a valid email adress in the code and save the page.
      5. Check your email inbox.
      6. Check the Mail sending statuses in administration.
      7.Check the console.

      Actual result:

      • After you access the page containing that code , you get the email in your inbox.
      • The problem is in the console, that generates multiple errors:
        2016-08-01 12:05:27,148 [Mail Sende2r Thread] ERROR o.x.m.i.DatabaseMailListener   - Error when looking for a previous mail status for message [wf6IcqpIFAxhHxKKHDZ37sZ5zoE=] of batch [7c9b4454-91a2-441f-a0a1-5e73f2e74afd].
        org.xwiki.mail.MailStoreException: Failed to load mail statuses matching the filter [{id=wf6IcqpIFAxhHxKKHDZ37sZ5zoE=}] from the database.
                at org.xwiki.mail.internal.DatabaseMailStatusStore.load(DatabaseMailStatusStore.java:142)
                at org.xwiki.mail.internal.DatabaseMailStatusStore.load(DatabaseMailStatusStore.java:98)
                at org.xwiki.mail.internal.DatabaseMailListener.retrieveExistingMailStatus(DatabaseMailListener.java:193)
                at org.xwiki.mail.internal.DatabaseMailListener.onSendMessageSuccess(DatabaseMailListener.java:126)
                at org.xwiki.mail.internal.thread.SendMailRunnable.sendMail(SendMailRunnable.java:184)
                at org.xwiki.mail.internal.thread.SendMailRunnable.runInternal(SendMailRunnable.java:117)
                at org.xwiki.mail.internal.thread.SendMailRunnable.run(SendMailRunnable.java:78)
                at java.lang.Thread.run(Unknown Source)
        Caused by: com.xpn.xwiki.XWikiException: Error number 3301 in 3: Exception while switching to database null
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.setDatabase(XWikiHibernateBaseStore.java:758)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:932)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:831)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.execute(XWikiHibernateBaseStore.java:1323)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.executeRead(XWikiHibernateBaseStore.java:1391)
                at org.xwiki.mail.internal.DatabaseMailStatusStore.load(DatabaseMailStatusStore.java:122)
                ... 7 common frames omitted
        Caused by: java.lang.NullPointerException: null
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getXWikiConfig(AbstractDataMigrationManager.java:300)
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDBVersionFromConfig(AbstractDataMigrationManager.java:375)
                at com.xpn.xwiki.store.migration.hibernate.HibernateDataMigrationManager.getDBVersionFromDatabase(HibernateDataMigrationManager.java:88)
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDataMigrationStatus(AbstractDataMigrationManager.java:421)
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDatabaseStatus(AbstractDataMigrationManager.java:564)
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.checkDatabase(AbstractDataMigrationManager.java:532)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.setDatabase(XWikiHibernateBaseStore.java:754)
                ... 12 common frames omitted
        2016-08-01 12:05:27,209 [Mail Sender Thread] WARN  o.x.m.i.DatabaseMailListener   - Forcing a new mail status for message [wf6IcqpIFAxhHxKKHDZ37sZ5zoE=] of batch [7c9b4454-91a2-441f-a0a1-5e73f2e74afd] to send_success state.
        2016-08-01 12:05:27,246 [Mail Sender Thread] ERROR o.x.m.i.DatabaseMailListener   - Failed to delete mail status [messageId = [wf6IcqpIFAxhHxKKHDZ37sZ5zoE=], batchId = [7c9b4454-91a2-441f-a0a1-5e73f2e74afd], state = [send_success], date = [Mon Aug 01 12:05:27 EEST 2016], recipients = [irina.hrehorciuc@xwiki.com]] from the database
        org.xwiki.mail.MailStoreException: Failed to delete mail status (message id [wf6IcqpIFAxhHxKKHDZ37sZ5zoE=]) from the database.
                at org.xwiki.mail.internal.DatabaseMailStatusStore.delete(DatabaseMailStatusStore.java:207)
                at org.xwiki.mail.internal.DatabaseMailListener.deleteStatus(DatabaseMailListener.java:227)
                at org.xwiki.mail.internal.DatabaseMailListener.onSendMessageSuccess(DatabaseMailListener.java:141)
                at org.xwiki.mail.internal.thread.SendMailRunnable.sendMail(SendMailRunnable.java:184)
                at org.xwiki.mail.internal.thread.SendMailRunnable.runInternal(SendMailRunnable.java:117)
                at org.xwiki.mail.internal.thread.SendMailRunnable.run(SendMailRunnable.java:78)
                at java.lang.Thread.run(Unknown Source)
        Caused by: com.xpn.xwiki.XWikiException: Error number 3301 in 3: Exception while switching to database null
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.setDatabase(XWikiHibernateBaseStore.java:758)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:932)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:831)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.execute(XWikiHibernateBaseStore.java:1323)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.executeWrite(XWikiHibernateBaseStore.java:1437)
                at org.xwiki.mail.internal.DatabaseMailStatusStore.delete(DatabaseMailStatusStore.java:195)
                ... 6 common frames omitted
        Caused by: java.lang.NullPointerException: null
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getXWikiConfig(AbstractDataMigrationManager.java:300)
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDBVersionFromConfig(AbstractDataMigrationManager.java:375)
                at com.xpn.xwiki.store.migration.hibernate.HibernateDataMigrationManager.getDBVersionFromDatabase(HibernateDataMigrationManager.java:88)
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDataMigrationStatus(AbstractDataMigrationManager.java:421)
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.getDatabaseStatus(AbstractDataMigrationManager.java:564)
                at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.checkDatabase(AbstractDataMigrationManager.java:532)
                at com.xpn.xwiki.store.XWikiHibernateBaseStore.setDatabase(XWikiHibernateBaseStore.java:754)
                ... 11 common frames omitted
        
      • If you access multiple times the test page, you will get all the emails, but in the Mail sending status all the statuses are prepare_success instead of sent_success (check the expected behavior in this tutorial https://www.youtube.com/watch?v=1ffnSZeR-So)
      • Also, if you add a wrong port to the email configuration, save it and access the test page, you will get in Mail sending status a new entry also with status prepare_success instead of send_error

      Attachments

        Activity

          People

            vmassol Vincent Massol
            ihrehorciuc Irina Hrehorciuc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: