Expand my Community achievements bar.

SOLVED

messageGatewayService : NPE

Avatar

Level 5
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 }
1 Accepted Solution

Avatar

Correct answer by
Level 10

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. 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

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. 

Avatar

Employee Advisor

Can you post the detailled stacktrace of the NPE?