Announcement Announcement Module
Collapse
No announcement yet.
Spring Velocity Help.. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Velocity Help..

    hi guys,

    i have a problem on my Spring-Velocity code:

    im getting this error;

    ResourceManager : unable to find resource 'C:\Documents and Settings\jason\workspace\PPCC-Survey\WebContent\WEB-INF\email.vm' in any resource loader.
    org.springframework.mail.MailPreparationException: Could not prepare mail; nested exception is org.apache.velocity.exception.ResourceNotFoundExce ption: Unable to find resource 'C:\Documents and Settings\jason\workspace\PPCC-Survey\WebContent\WEB-INF\email.vm'
    Caused by: org.apache.velocity.exception.ResourceNotFoundExce ption: Unable to find resource 'C:\Documents and Settings\jason\workspace\PPCC-Survey\WebContent\WEB-INF\email.vm'
    at org.apache.velocity.runtime.resource.ResourceManag erImpl.loadResource(ResourceManagerImpl.java:452)
    at org.apache.velocity.runtime.resource.ResourceManag erImpl.getResource(ResourceManagerImpl.java:335)
    at org.apache.velocity.runtime.RuntimeInstance.getTem plate(RuntimeInstance.java:1102)
    at org.apache.velocity.app.VelocityEngine.mergeTempla te(VelocityEngine.java:498)
    at org.apache.velocity.app.VelocityEngine.mergeTempla te(VelocityEngine.java:473)
    at org.springframework.ui.velocity.VelocityEngineUtil s.mergeTemplate(VelocityEngineUtils.java:58)
    at org.springframework.ui.velocity.VelocityEngineUtil s.mergeTemplateIntoString(VelocityEngineUtils.java :122)
    at com.ppcc.survey.surveyassignment.action.SurveyAssi gnmentAction$1.prepare(SurveyAssignmentAction.java :182)
    at org.springframework.mail.javamail.JavaMailSenderIm pl.send(JavaMailSenderImpl.java:344)


    im my applicationContext i have this:

    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl">
    <property name="host" value="10.10.1.23"/>
    </bean>

    <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEng ineFactoryBean">
    <property name="velocityProperties">
    <value>
    resource.loader=class
    class.resource.loader.class=org.apache.velocity.ru ntime.resource.loader.ClasspathResourceLoader
    </value>
    </property>
    </bean>


    <bean id = "surveyAssignmentAction" scope = "prototype" class = "com.action.SurveyAssignmentAction">

    <property name="mailSender" ref="mailSender"/>
    <property name="velocityEngine" ref="velocityEngine"/>

    </bean>

    in my class i have:

    private void sendConfirmationEmail(final Email email) {
    System.out.println("here!!!!!!!!!!!!!!!");

    MimeMessagePreparator preparator = new MimeMessagePreparator() {

    public void prepare(MimeMessage mimeMessage) throws Exception {
    MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
    message.setTo(email.getEmail());
    message.setFrom("[email protected]"); // could be parameterized...
    Map model = new HashMap();
    model.put("email", email);
    String text = VelocityEngineUtils.mergeTemplateIntoString(
    velocityEngine,ServletActionContext.getRequest.get RealPath("/WEB-INF/email.vm", model);
    message.setText(text, true);
    }
    };

    this.mailSender.send(preparator);


    }


    please help...


    GodSpeed
    my_aro

  • #2
    Hi,
    If you use org.apache.velocity.runtime.resource.loader.Classp athResourceLoader, the templates are supposed to be under web-inf/classes folder. I think you have to use org.apache.velocity.runtime.resource.loader.FileRe sourceLoader if you want to locate the templates this way.

    Cheers,
    Juan

    Comment

    Working...
    X