In the signup process of Spring Lemon, I'm trying to send the verification email.
I've put messages_en.properties and messages_fr.properties in my resources
folder.
Here is the relevant content of messages_en.properties
com.naturalprogrammer.spring.verifyEmail: Hi,<br/><br/>Your email id at XYZ is unverified. Please click the link below to get verified:<br/><br/>{0}<br/><br/>
But when I look at the logs, it sends the mail without replacing the {0} by the verifyLink.
I looked at the code and figured out that this portion of LemonService is the isse :
// send the mail
mailSender.send(user.getEmail(),
LemonUtil.getMessage("com.naturalprogrammer.spring.verifySubject"),
LemonUtil.getMessage(
"com.naturalprogrammer.spring.verifyEmail", verifyLink));
But the actual work is being done by this code in LemonUtil.java :
/**
* Gets a message from messages.properties
*
* @param messageKey the key of the message
* @param args any arguments
*/
public static String getMessage(String messageKey, Object... args) {
// http://stackoverflow.com/questions/10792551/how-to-obtain-a-current-user-locale-from-spring-without-passing-it-as-a-paramete
return messageSource.getMessage(messageKey, args,
LocaleContextHolder.getLocale());
}
I managed to solve it somehow by deleting the {0} in the .properties, and by adding the link myself like this :
// send the mail
mailSender.send(user.getEmail(),
LemonUtil.getMessage("com.naturalprogrammer.spring.verifySubject"),
LemonUtil.getMessage(
"com.naturalprogrammer.spring.verifyEmail", verifyLink) + verifyLink);
I think the getMessage method of org.springframework.context.MessageSource is not working properly. My question is : what could prevent messageSource from working ?