org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/email/text/user-notification-function-mail.vm [line 3,column 27] : ${consolidatedVendorName} is not a valid reference.

Atlassian JIRA | Andreas Vogel | 1 decade ago
  1. 0

    Hello, I'm developing a post function which allows a user to specify an email address to which a custom email is sent (custom meaning a custom email vm template). The email does get sent with the correct template, however the problem I'm having is that the velocity params are not populated in the template. In another words I get > Today is: ${today_date} > instead of : > Today is: 08/11/2005. > The stack trace shows the following errors where ${consolidatedVendorName} is one of the params in the template file. .. .. .. 2005-08-11 13:23:25,157 WARN [velocity] org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/email/text/user-notification-function-mail.vm [line 3,column 27] : ${consolidatedVendorName} is not a valid reference. at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:277) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230) at org.apache.velocity.Template.merge(Template.java:256) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:450) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:76) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:60) at com.atlassian.jira.mail.UserMailQueueItem.send(UserMailQueueItem.java:50) .. .. .. Code is below Thanks, -Andreas > > public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException { Issue issue = (Issue) transientVars.get("issue"); com.opensymphony.user.User reporter = issue.getReporter(); try { UserEvent ue = new UserEvent(createParamsMap(issue, transientVars), reporter); String template = "user-notification-function-mail.vm"; MailQueueItem item = new UserMailQueueItem(ue, computeSubject(issue,args), template); ManagerFactory.getMailQueue().addItem(item); } catch (Exception e) { log.error("Failed to send mail", e); } } private Map createParamsMap(Issue issue, Map transientVars) { // get the custom fields CustomFieldManager cfm = ManagerFactory.getCustomFieldManager(); skuField = cfm.getCustomFieldObjectByName(skuFieldName); skuDescriptionField = cfm.getCustomFieldObjectByName(skuDescriptionFieldName); consolidatedVendorNameField = cfm.getCustomFieldObjectByName(consolidatedVendorNameFieldName); merchantField = cfm.getCustomFieldObjectByName(merchantFieldName); // custom fields String skuValue = (issue.getCustomFieldValue(skuField)).toString(); String skuDescriptionValue = (issue.getCustomFieldValue(skuDescriptionField)).toString(); String consolidatedVendorNameValue = (issue.getCustomFieldValue(consolidatedVendorNameField)).toString(); String merchantValue = (issue.getCustomFieldValue(merchantField)).toString(); Map paramsMap = new HashMap(); // Sku, skuDescription, Merchant, consolidated vendor name // Blank Size Length, Blank Size Width paramsMap.put("sku", skuValue); paramsMap.put("skuDescription", skuDescriptionValue); paramsMap.put("merchant", merchantValue); paramsMap.put("consolidatedVendorName", consolidatedVendorNameValue); //paramsMap.put("blankSizeLength", ""); //paramsMap.put("blankSizeWidth", ""); return paramsMap; } private String computeSubject(Issue issue, Map args) { StringBuffer subject = new StringBuffer(); // Add the issue new status Status issueStatus = issue.getStatusObject(); subject.append(issueStatus.getName()); // Add the issue name subject.append(": ("); subject.append(issue.getKey()); subject.append(")"); // Add the issue description subject.append(" "); subject.append((String) issue.getSummary()); return subject.toString(); } private String getEmails(Issue issue, Map args) throws EntityNotFoundException { StringBuffer emails = new StringBuffer(); // Add reporter com.opensymphony.user.User reporter = issue.getReporter(); emails.append(reporter.getEmail()); // Add assignee emails.append(','); com.opensymphony.user.User assignee = issue.getAssignee(); emails.append(assignee.getEmail()); // Add additional individual emails String individualEmails = (String) args.get("field.notifyEmail"); StringTokenizer tokens = new StringTokenizer(individualEmails, ", "); while (tokens.hasMoreTokens()) { String token = tokens.nextToken(); emails.append(','); User user = UserManager.getInstance().getUser(token); emails.append(user.getEmail()); } return emails.toString(); }

    Atlassian JIRA | 1 decade ago | Andreas Vogel
    org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/email/text/user-notification-function-mail.vm [line 3,column 27] : ${consolidatedVendorName} is not a valid reference.
  2. 0

    Hello, I'm developing a post function which allows a user to specify an email address to which a custom email is sent (custom meaning a custom email vm template). The email does get sent with the correct template, however the problem I'm having is that the velocity params are not populated in the template. In another words I get > Today is: ${today_date} > instead of : > Today is: 08/11/2005. > The stack trace shows the following errors where ${consolidatedVendorName} is one of the params in the template file. .. .. .. 2005-08-11 13:23:25,157 WARN [velocity] org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/email/text/user-notification-function-mail.vm [line 3,column 27] : ${consolidatedVendorName} is not a valid reference. at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:277) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230) at org.apache.velocity.Template.merge(Template.java:256) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:450) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:76) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:60) at com.atlassian.jira.mail.UserMailQueueItem.send(UserMailQueueItem.java:50) .. .. .. Code is below Thanks, -Andreas > > public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException { Issue issue = (Issue) transientVars.get("issue"); com.opensymphony.user.User reporter = issue.getReporter(); try { UserEvent ue = new UserEvent(createParamsMap(issue, transientVars), reporter); String template = "user-notification-function-mail.vm"; MailQueueItem item = new UserMailQueueItem(ue, computeSubject(issue,args), template); ManagerFactory.getMailQueue().addItem(item); } catch (Exception e) { log.error("Failed to send mail", e); } } private Map createParamsMap(Issue issue, Map transientVars) { // get the custom fields CustomFieldManager cfm = ManagerFactory.getCustomFieldManager(); skuField = cfm.getCustomFieldObjectByName(skuFieldName); skuDescriptionField = cfm.getCustomFieldObjectByName(skuDescriptionFieldName); consolidatedVendorNameField = cfm.getCustomFieldObjectByName(consolidatedVendorNameFieldName); merchantField = cfm.getCustomFieldObjectByName(merchantFieldName); // custom fields String skuValue = (issue.getCustomFieldValue(skuField)).toString(); String skuDescriptionValue = (issue.getCustomFieldValue(skuDescriptionField)).toString(); String consolidatedVendorNameValue = (issue.getCustomFieldValue(consolidatedVendorNameField)).toString(); String merchantValue = (issue.getCustomFieldValue(merchantField)).toString(); Map paramsMap = new HashMap(); // Sku, skuDescription, Merchant, consolidated vendor name // Blank Size Length, Blank Size Width paramsMap.put("sku", skuValue); paramsMap.put("skuDescription", skuDescriptionValue); paramsMap.put("merchant", merchantValue); paramsMap.put("consolidatedVendorName", consolidatedVendorNameValue); //paramsMap.put("blankSizeLength", ""); //paramsMap.put("blankSizeWidth", ""); return paramsMap; } private String computeSubject(Issue issue, Map args) { StringBuffer subject = new StringBuffer(); // Add the issue new status Status issueStatus = issue.getStatusObject(); subject.append(issueStatus.getName()); // Add the issue name subject.append(": ("); subject.append(issue.getKey()); subject.append(")"); // Add the issue description subject.append(" "); subject.append((String) issue.getSummary()); return subject.toString(); } private String getEmails(Issue issue, Map args) throws EntityNotFoundException { StringBuffer emails = new StringBuffer(); // Add reporter com.opensymphony.user.User reporter = issue.getReporter(); emails.append(reporter.getEmail()); // Add assignee emails.append(','); com.opensymphony.user.User assignee = issue.getAssignee(); emails.append(assignee.getEmail()); // Add additional individual emails String individualEmails = (String) args.get("field.notifyEmail"); StringTokenizer tokens = new StringTokenizer(individualEmails, ", "); while (tokens.hasMoreTokens()) { String token = tokens.nextToken(); emails.append(','); User user = UserManager.getInstance().getUser(token); emails.append(user.getEmail()); } return emails.toString(); }

    Atlassian JIRA | 1 decade ago | Andreas Vogel
    org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/email/text/user-notification-function-mail.vm [line 3,column 27] : ${consolidatedVendorName} is not a valid reference.
  3. 0

    When you leave off the subject, and there is no defaultSummary in emh.properties, the hint-o-gram generated says: > No summary provided, no email subkect, no default. This message will eventually be rejected. subkect s/b subject. Also at the bottom where it's outputting the details of the original email, the subject shows up as "$message.getSubject()" And in the logs, I have: 2011-02-25 10:35:40,525 JiraQuartzScheduler_Worker-3 WARN ServiceRunner ITSM Service [velocity] org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/email/jemh/html/errorhint.vm [line 53,column 83] : $message.getSubject() is not a valid reference. at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:277) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230) at org.apache.velocity.Template.merge(Template.java:256) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:422) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:77) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:61) at com.javahollic.jira.emh.service.AbstractMessageHandler.encodeAndSendEmail(AbstractMessageHandler.java:855) at com.javahollic.jira.emh.service.AbstractMessageHandler.sendErrorHintsToEmailSender(AbstractMessageHandler.java:788) at com.javahollic.jira.emh.service.AbstractMessageHandler.sendErrorHintsToEmailSender(AbstractMessageHandler.java:664) at com.javahollic.jira.emh.service.EMHIssueHandler.handleMessage(EMHIssueHandler.java:207) at com.javahollic.jira.emh.service.CreateOrCommentHandler.handleMessage(CreateOrCommentHandler.java:76) at com.atlassian.jira.service.services.mail.MailFetcherService.run(MailFetcherService.java:189) at com.atlassian.jira.service.JiraServiceContainerImpl.run(JiraServiceContainerImpl.java:67) at com.atlassian.jira.service.ServiceRunner.execute(ServiceRunner.java:48) at org.quartz.core.JobRunShell.run(JobRunShell.java:191) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516) Can that be prevented with $!message.getSubject() ? Affects 0.9.6.2-snapshot

    JIRA | 6 years ago | Mike Curwen
    org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/email/jemh/html/errorhint.vm [line 53,column 83] : $message.getSubject() is not a valid reference.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    2005-01-18 02:22:41,470 ERROR [velocity] Left side ($constant.getString("iconurl").startsWith("http://")) of '==' operation has null value. If a reference, it may not be in the context. Operation not possible. templates/plugins/jira/projectpanels/popularissues-panel.vm [line 1, column 61] 2005-01-18 02:22:41,473 WARN [velocity] org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/plugins/jira/projectpanels/popularissues-panel.vm [line 4,column 27] : $constant.getString("iconurl") is not a valid reference. at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:277) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230) at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:89) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230) at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:172) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:114) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55) at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:166) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:114) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55) at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:70) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230) at org.apache.velocity.Template.merge(Template.java:256) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:450) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:97) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:77) at com.atlassian.jira.plugin.JiraResourcedModuleDescriptor.getHtml(JiraResourcedModuleDescriptor.java:79) at com.atlassian.jira.plugin.projectpanel.impl.PopularIssuesProjectTabPanel.getHtml(PopularIssuesProjectTabPanel.java:52) at com.atlassian.jira.web.action.browser.Browser.getProjectTabHtml(Browser.java:292)

    Atlassian JIRA | 1 decade ago | Jeff Turner
    org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/plugins/jira/projectpanels/popularissues-panel.vm [line 4,column 27] : $constant.getString("iconurl") is not a valid reference.
  6. 0

    2005-01-18 02:22:41,432 WARN [velocity] org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/plugins/jira/projectpanels/popularissues-panel.vm [line 4,column 174] : $constant.getString("description") is not a valid reference. at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:277) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230) at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:89) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230) at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:172) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:114) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55) at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:166) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:114) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55) at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:70) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230) at org.apache.velocity.Template.merge(Template.java:256) at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:450) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:97) at com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:77) at com.atlassian.jira.plugin.JiraResourcedModuleDescriptor.getHtml(JiraResourcedModuleDescriptor.java:79) at com.atlassian.jira.plugin.projectpanel.impl.PopularIssuesProjectTabPanel.getHtml(PopularIssuesProjectTabPanel.java:52) at com.atlassian.jira.web.action.browser.Browser.getProjectTabHtml(Browser.java:292)

    Atlassian JIRA | 1 decade ago | Jeff Turner
    org.apache.velocity.runtime.exception.ReferenceException: reference : template = templates/plugins/jira/projectpanels/popularissues-panel.vm [line 4,column 174] : $constant.getString("description") is not a valid reference.

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.apache.velocity.runtime.exception.ReferenceException

      reference : template = templates/email/text/user-notification-function-mail.vm [line 3,column 27] : ${consolidatedVendorName} is not a valid reference.

      at org.apache.velocity.runtime.parser.node.ASTReference.render()
    2. Apache Velocity
      VelocityEngine.mergeTemplate
      1. org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:277)
      2. org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
      3. org.apache.velocity.Template.merge(Template.java:256)
      4. org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:450)
      4 frames
    3. com.atlassian.velocity
      DefaultVelocityManager.getEncodedBody
      1. com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:76)
      2. com.atlassian.velocity.DefaultVelocityManager.getEncodedBody(DefaultVelocityManager.java:60)
      2 frames
    4. com.atlassian.jira
      UserMailQueueItem.send
      1. com.atlassian.jira.mail.UserMailQueueItem.send(UserMailQueueItem.java:50)
      1 frame