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

NullPointerException when trying to create a mail from a not existing mail template document

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • 7.0.1
    • Mail
    • Unknown

    Description

      Something like "Template [Space.MailTemplate] does not exist" would have been nicer

      Here is the stack trace:

      java.lang.NullPointerException: null
      	at org.xwiki.mail.internal.factory.template.DefaultMailTemplateManager.getMailObjectsCount(DefaultMailTemplateManager.java:154) ~[xwiki-platform-mail-send-default-7.0.1.jar:na]
      	at org.xwiki.mail.internal.factory.template.DefaultMailTemplateManager.getObjectMailNumber(DefaultMailTemplateManager.java:126) ~[xwiki-platform-mail-send-default-7.0.1.jar:na]
      	at org.xwiki.mail.internal.factory.template.DefaultMailTemplateManager.evaluate(DefaultMailTemplateManager.java:93) ~[xwiki-platform-mail-send-default-7.0.1.jar:na]
      	at org.xwiki.mail.internal.factory.template.SecureMailTemplateManager.evaluate(SecureMailTemplateManager.java:71) ~[xwiki-platform-mail-send-default-7.0.1.jar:na]
      	at org.xwiki.mail.internal.factory.template.AbstractTemplateMimeMessageFactory.createMessage(AbstractTemplateMimeMessageFactory.java:94) ~[xwiki-platform-mail-send-default-7.0.1.jar:na]
      	at org.xwiki.mail.internal.factory.template.AbstractTemplateMimeMessageFactory.createMessage(AbstractTemplateMimeMessageFactory.java:48) ~[xwiki-platform-mail-send-default-7.0.1.jar:na]
      	at org.xwiki.mail.script.MailSenderScriptService.createMessage(MailSenderScriptService.java:96) ~[xwiki-platform-mail-send-default-7.0.1.jar:na]
      	at org.xwiki.mail.script.MailSenderScriptService$createMessage.call(Unknown Source) ~[na:na]
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) ~[groovy-all-2.4.2.jar:2.4.2]
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110) ~[groovy-all-2.4.2.jar:2.4.2]
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:138) ~[groovy-all-2.4.2.jar:2.4.2]
      	at InvoiceManager.notify(Script1.groovy:417) ~[na:na]
      	at InvoiceManager$notify.call(Unknown Source) ~[na:na]
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) ~[groovy-all-2.4.2.jar:2.4.2]
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110) ~[groovy-all-2.4.2.jar:2.4.2]
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122) ~[groovy-all-2.4.2.jar:2.4.2]
      	at InvoiceNotificationsListener.onEvent(Script1.groovy:589) ~[na:na]
      	at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:304) [xwiki-commons-observation-local-7.0.1.jar:na]
      	at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:269) [xwiki-commons-observation-local-7.0.1.jar:na]
      	at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:1443) [xwiki-platform-legacy-oldcore-7.0.1.jar:na]
      	at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:1367) [xwiki-platform-legacy-oldcore-7.0.1.jar:na]
      	at com.xpn.xwiki.XWiki.restoreFromRecycleBin(XWiki.java:5957) [xwiki-platform-legacy-oldcore-7.0.1.jar:na]
      	at com.xpn.xwiki.web.UndeleteAction.action(UndeleteAction.java:75) [xwiki-platform-legacy-oldcore-7.0.1.jar:na]
      	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:344) [xwiki-platform-legacy-oldcore-7.0.1.jar:na]
      	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:146) [xwiki-platform-legacy-oldcore-7.0.1.jar:na]
      	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425) [struts-core-1.3.10.jar:1.3.10]
      	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) [struts-core-1.3.10.jar:1.3.10]
      	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) [struts-core-1.3.10.jar:1.3.10]
      	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) [struts-core-1.3.10.jar:1.3.10]
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) [javax.servlet-api-3.1.0.jar:3.1.0]
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [javax.servlet-api-3.1.0.jar:3.1.0]
      	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:769) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1667) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:115) [xwiki-platform-legacy-oldcore-7.0.1.jar:na]
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:127) [xwiki-platform-wysiwyg-server-7.0.1.jar:na]
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63) [xwiki-platform-container-servlet-7.0.1.jar:na]
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:66) [xwiki-platform-webdav-server-7.0.1.jar:na]
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208) [xwiki-platform-container-servlet-7.0.1.jar:na]
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111) [xwiki-platform-container-servlet-7.0.1.jar:na]
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577) [jetty-security-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.Server.handle(Server.java:497) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [jetty-io-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:610) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:539) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
      	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
      

      The nullpointer comes from the fact that XWikiDocument#getXObjects return null and not empty list when there is no xobject with the passed xclass.

      Attachments

        Issue Links

          Activity

            People

              tmortagne Thomas Mortagne
              tmortagne Thomas Mortagne
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: