messageGatewayService : NPE | Community
Skip to main content
Level 5
October 16, 2015
Solved

messageGatewayService : NPE

  • October 16, 2015
  • 2 replies
  • 730 views
Hi, I am getting NPE when calling EmailService class's function sendEmail(). @Component(immediate = true, metatype = true, label = "Mail Service") @Service(EmailService.class) public class EmailService { @Reference private MessageGateway<HtmlEmail> messageGateway; @Reference private MessageGatewayService messageGatewayService; public void sendEmail() { ArrayList<InternetAddress> emailRecipients = new ArrayList<InternetAddress>(); HtmlEmail email = new HtmlEmail(); try { emailRecipients.add(new InternetAddress("recipient.gmail.com")); email.setTo(emailRecipients); email.setSubject("This is subject"); email.setHtmlMsg("Email testing is on.."); logger.info("messageGatewayService : " + messageGatewayService); messageGateway = messageGatewayService.getGateway(HtmlEmail.class); // Check the logs to see that messageGateway is not null logger.info("messageGateway : " + messageGateway); messageGateway.send(email); } //Catch Block }
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

See this community article where this is used successfully in a custom AEM 5.6 workflow step:

http://helpx.adobe.com/experience-manager/using/creating-custom-aem-workflow-steps.html

Also - as discussed in this article - configure AEM to use an email server. 

2 replies

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

Can you post the detailled stacktrace of the NPE?

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

See this community article where this is used successfully in a custom AEM 5.6 workflow step:

http://helpx.adobe.com/experience-manager/using/creating-custom-aem-workflow-steps.html

Also - as discussed in this article - configure AEM to use an email server.