0

I have seen the solution regarding this question but i did not found any solution for my scenario. my mailsender.xml is

<bean id="velocityEngine"
    class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
    <property name="resourceLoaderPath" value="/email_Templates" />
    <property name="preferFileSystemAccess" value="false" />
</bean>

and my velocity implementation code is..

public void sendUserActivationMail(User user, String requestUrl) throws Exception {
    String plainText = System.currentTimeMillis() + "##" + user.getUserId();
    userDao.insertRegistraionToken(user.getUserId(), plainText, "123456");

    String token = AESEncrypter.encrypt(plainText);
    String url = requestUrl + "/activateUser.htm?token=" + URLEncoder.encode(token, "UTF-8");
    try {
        Map<String, Object> storemap = new HashMap<String, Object>();
        storemap.put("toUserName", user.getName());
        storemap.put("fromUseerName", ApplicationConstants.TEAM_NAME);
        storemap.put("url", url);
        String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "verificationEmail.vm", "UTF-8", storemap);

        mailService.sendMail(senderMailId, new String[] { user.getEmail() }, null, "Registration Activation", text);
    } catch (Exception e) {
        logger.println(IMessage.ERROR,new StringBuilder(CLASS_NAME).append("::runProfileIncompleteCron()  exception ==" + e));
    }

}

my folder structure is-

src/main/resources
    |_email_Templates
       |
       |__verificationEmail.vm

But is shows error

org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'verificationEmail.vm'

Sachin PATIL
  • 745
  • 1
  • 9
  • 16
MANITORATION
  • 557
  • 2
  • 5
  • 19
  • Does your bean that contains the `sendUserActivationMail` method refer to the `VelocityEngine` bean? – VHS Mar 08 '17 at 19:19
  • This link will resolve your issue :http://stackoverflow.com/questions/9051413/unable-to-find-velocity-template-resources – soorapadman Mar 09 '17 at 08:19

0 Answers0