Specific types of Jira notifications are not sent to any user due to invalid email template-ID mapping
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The purpose of this KB article is to describe a scenario where specific types of Jira notifications are no longer sent by the application. One example of notification that may be impacted is the Filter Subscription Email, but note that other types of notifications may be impacted by the same issue.
Diagnosis
Look for the error below in the Jira application log files (<JIRA_HOME>/log/atlassian-jira.log*). If you can find this error, then this KB article is relevant and you may move on to the Solution section:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
2024-06-06 00:26:00,368+1000 Sending mailitem com.atlassian.jira.mail.SubscriptionSingleRecepientMailQueueItem owner: 'someuser(maniyarr)' ERROR someuser Mail Queue Service [c.a.jira.template.DefaultTemplateManager] Error parsing email-template-id-mappings.xml: electric.xml.ParseException: java.io.IOException: <...templatemappings> does not match </...templatemapping>
line 101, char 22: ... </templatemapping>
electric.xml.ParseException: java.io.IOException: <...templatemappings> does not match </...templatemapping>
line 101, char 22: ... </templatemapping>
at electric.xml.NodeReader.parse(NodeReader.java:98)
at electric.xml.Document.<init>(Document.java:197)
at electric.xml.Document.<init>(Document.java:183)
at com.atlassian.jira.template.DefaultTemplateManager.initTemplates(DefaultTemplateManager.java:240)
at com.atlassian.jira.template.DefaultTemplateManager.access$000(DefaultTemplateManager.java:42)
at com.atlassian.jira.template.DefaultTemplateManager$1.create(DefaultTemplateManager.java:58)
at com.atlassian.jira.template.DefaultTemplateManager$1.create(DefaultTemplateManager.java:55)
at io.atlassian.util.concurrent.ResettableLazyReference$InternalReference.create(ResettableLazyReference.java:185)
at io.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:332)
at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:150)
at io.atlassian.util.concurrent.LazyReference.get(LazyReference.java:116)
at io.atlassian.util.concurrent.ResettableLazyReference.get(ResettableLazyReference.java:95)
at com.atlassian.jira.template.DefaultTemplateManager.getAllTemplateFilesMap(DefaultTemplateManager.java:153)
at com.atlassian.jira.template.DefaultTemplateManager.getTemplateFilename(DefaultTemplateManager.java:222)
at com.atlassian.jira.template.DefaultTemplateManager.getTemplateContentFromResource(DefaultTemplateManager.java:181)
at com.atlassian.jira.template.DefaultTemplateManager.getTemplateContent(DefaultTemplateManager.java:165)
at com.atlassian.jira.mail.MailingListCompiler.evaluateEmails(MailingListCompiler.java:270)
at com.atlassian.jira.mail.MailingListCompiler.access$300(MailingListCompiler.java:52)
at com.atlassian.jira.mail.MailingListCompiler$NotificationCompiler.lambda$addEmailsToQueue$0(MailingListCompiler.java:475)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
at com.atlassian.jira.mail.MailingListCompiler$NotificationCompiler.addEmailsToQueue(MailingListCompiler.java:477)
at com.atlassian.jira.mail.MailingListCompiler$NotificationCompiler.sendLists(MailingListCompiler.java:447)
at com.atlassian.jira.mail.MailingListCompiler$NotificationCompiler.sendNoLevelsIgnoreGroup(MailingListCompiler.java:423)
at com.atlassian.jira.mail.MailingListCompiler$NotificationCompiler.evaluateForAll(MailingListCompiler.java:419)
at com.atlassian.jira.mail.MailingListCompiler.prepareEmail(MailingListCompiler.java:183)
at com.atlassian.jira.mail.SubscriptionSingleRecepientMailQueueItem.sendSearchRequestEmail(SubscriptionSingleRecepientMailQueueItem.java:133)
at com.atlassian.jira.mail.SubscriptionSingleRecepientMailQueueItem.send(SubscriptionSingleRecepientMailQueueItem.java:103)
at com.atlassian.jira.mail.CountingMailQueueItemWrapper.send(CountingMailQueueItemWrapper.java:26)
at com.atlassian.mail.queue.MailQueueImpl.sendBufferUnderLock(MailQueueImpl.java:83)
at com.atlassian.mail.queue.MailQueueImpl.sendBuffer(MailQueueImpl.java:47)
at com.atlassian.jira.mail.JiraMailQueue.lambda$sendAndUpdateIpdMetric$0(JiraMailQueue.java:154)
at com.atlassian.jira.util.velocity.DefaultVelocityRequestContextFactory.runWithStaticBaseUrl(DefaultVelocityRequestContextFactory.java:110)
at com.atlassian.jira.util.DefaultBaseUrl.runWithStaticBaseUrl(DefaultBaseUrl.java:56)
at com.atlassian.jira.mail.JiraMailQueue.sendAndUpdateIpdMetric(JiraMailQueue.java:153)
at com.atlassian.jira.mail.JiraMailQueue.sendBuffer(JiraMailQueue.java:70)
at com.atlassian.jira.service.services.mail.MailQueueService.run(MailQueueService.java:21)
at com.atlassian.jira.service.JiraServiceContainerImpl.run(JiraServiceContainerImpl.java:68)
at com.atlassian.jira.service.ServiceRunner.runService(ServiceRunner.java:62)
at com.atlassian.jira.service.ServiceRunner.runServiceId(ServiceRunner.java:44)
at com.atlassian.jira.service.ServiceRunner.runJob(ServiceRunner.java:32)
at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:134)
at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:106)
at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:90)
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.launchJob(CaesiumSchedulerService.java:500)
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeLocalJobWithRetryOnFailure(CaesiumSchedulerService.java:463)
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeQueuedJob(CaesiumSchedulerService.java:413)
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeJob(SchedulerQueueWorker.java:66)
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(SchedulerQueueWorker.java:60)
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:35)
at java.base/java.lang.Thread.run(Unknown Source)
Cause
As described in the KB article How to create a custom mail template in Jira Data Center, it is possible to create new email templates to be associated with a specific Jira event. To map the new custom template to a specific event, it is necessary to edit the <Jira Installation folder>/atlassian-jira/WEB-INF/classes/email-template-id-mappings.xml
file.
If this file has an invalid format (for example, it's missing an opening or closing tag), the Jira application will fail to parse this file and fetch the mapping between the event IDs and templates. As a result, some notifications will never be sent by the Jira application, such as the Filter Subscription email.
Solution
To fix this issue, you will need to fix the format of the <Jira Installation folder>/atlassian-jira/WEB-INF/classes/email-template-id-mappings.xml
file. The way this file needs to be fixed will depend on how it is corrupted.
If we refer to the error from the log snippet above, we can see that the error was complaining about a specific line, therefore checking this line is a good way to start:
1
2
<...templatemappings> does not match </...templatemapping>
line 101, char 22: ... </templatemapping>
Alternatively, you might use the XML validator tool of your choice (for example https://www.w3schools.com/xml/xml_validator.asp) to validate this file, and identify the line(s) where the corruption is happening.
Once the XML file is fixed, you will need to:
Apply the same fix to all the Jira nodes in your cluster (in case of a cluster of nodes)
Re-start the Jira application (or all the nodes in case of a cluster), for the fix to be taken into account
Example
Below is an example of extract from an invalid XML file. We can see that the "Issue Restored" template is missing the opening tag <templatemapping id="XXX">. To fix it, this opening tag needs to be added:
1
<templatemapping id="18"><name>Issue Archived</name><template>issuearchived.vm</template><templatetype>issueevent</templatetype></templatemapping><name>Issue Restored</name><template>issuerestored.vm</template><templatetype>issueevent</templatetype></templatemapping>
Was this helpful?