Results 1 to 1 of 1

Thread: Hi

  1. #1
    trilochan is offline Member
    Join Date
    Sep 2009
    Posts
    3
    Rep Power
    0

    Default Hi

    Hi, I didnt know where to post this msg. So here it is. I am trying to write a velocity template program using eclipse. Here's the code:
    package velocityExample;

    import java.io.StringWriter;

    import org.apache.velocity.Template;
    import org.apache.velocity.VelocityContext;
    import org.apache.velocity.app.VelocityEngine;

    public class HelloWorld {
    public static void main( String[] args )
    throws Exception {
    VelocityEngine ve = new VelocityEngine();
    ve.init();
    Template t = new Template();
    ve.getTemplate("helloworld.vm");
    VelocityContext context = new VelocityContext();
    context.put("name", "World");
    StringWriter writer = new StringWriter();
    t.merge( context, writer );
    System.out.println( writer.toString() );
    }
    }
    The template file "helloworld.vm" is present in the same folder.
    But still it shows a error
    Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundExce ption: Unable to find resource 'helloworld.vm'
    at org.apache.velocity.runtime.resource.ResourceManag erImpl.loadResource(ResourceManagerImpl.java:458)
    at org.apache.velocity.runtime.resource.ResourceManag erImpl.getResource(ResourceManagerImpl.java:341)
    at org.apache.velocity.runtime.RuntimeInstance.getTem plate(RuntimeInstance.java:831)
    at org.apache.velocity.runtime.RuntimeInstance.getTem plate(RuntimeInstance.java:813)
    at org.apache.velocity.app.VelocityEngine.getTemplate (VelocityEngine.java:470)
    at velocityExample.HelloWorld.main(HelloWorld.java:15 )
    Please help. ( I have tried by giving the absolute path also.)
    Last edited by trilochan; 09-04-2009 at 11:35 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •