Hello,
I am getting a NullPointerException with VelocityEngineUtils.
org.springframework.ui.velocity.VelocityEngineUtil s.mergeTemplate(VelocityEngineUtils.java:55)
I am guessing it can't find the template.
I am trying to merge a template so I can email the result.
Here is my applicationContext.xml snippet:
And the relevant Java Code:Code:<!-- Mail Confiruguration --> <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"> <property name="resourceLoaderPath"><value>/WEB-INF/templates</value></property> </bean> <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host"><value>mail.xxx.org</value></property> <property name="username"><value>xxx</value></property> <property name="password"><value>xxx</value></property> </bean> <bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage"/> <bean id="managerTarget" class="com.xxx.MailSender"> <property name="mailSender"><ref bean="mailSender"/></property> <property name="message"><ref bean="mailMessage"/></property> <property name="velocityEngine"><ref bean="velocityEngine"/></property> </bean>
Code:SimpleMailMessage msg = new SimpleMailMessage(); msg.setFrom("lostpassword@xxx.org"); msg.setSubject("Lost Password Request"); msg.setTo(reg.getEmail()); Map<String, Registrant> model = new HashMap<String, Registrant>(); model.put("registrant", reg); String result = null; try { result = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "lostPassword.vm", model); } catch(VelocityException e) { log.error(e); } msg.setText(result); try { mailSender.send(msg); } catch (MailException ex) { log.error(ex); }


Reply With Quote
roperty-placeholder file:C:/Email/AppProps.properties" />