title: Unable to find velocity template resources
body: <p>Just a simple velocity standalone app based on maven structure. Here is the code snippet written in Scala to render the template <code>helloworld.vm</code> in <code>${basedir}/src/main/resources</code> folder: </p>
  
  <pre><code>com.ggd543.velocitydemo
  
  import org.apache.velocity.app.VelocityEngine
  import org.apache.velocity.VelocityContext
  import java.io.StringWriter
  
  /**
   * @author ${user.name}
   */
  object App {
  
    def main(args: Array[String]) {
      //First , get and initialize an engine
      val ve = new VelocityEngine();
      ve.init();
  
      //Second, get the template
      val resUrl = getClass.getResource("/helloworld.vm")
      val t = ve.getTemplate("helloworld.vm");   // not work 
  //    val t = ve.getTemplate("/helloworld.vm");  // not work
  //    val t = ve.getTemplate(resUrl.toString);  // not work yet
      //Third, create a context and add data
      val context = new VelocityContext();
      context.put("name", "Archer")
      context.put("site", "http://www.baidu.com")
      //Finally , render the template into a StringWriter
      val sw = new StringWriter
      t.merge(context, sw)
      println(sw.toString);
    }
  
  }
  </code></pre>
  
  <p>when to compile and run the program, I got the following error:</p>
  
  <pre><code>2012-1-29 14:03:59 org.apache.velocity.runtime.log.JdkLogChute log
  严重: ResourceManager : unable to find resource '/helloworld.vm' in any resource loader.
  Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource '/helloworld.vm'
      at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
      at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:352)
      at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1533)
      at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1514)
      at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:373)
      at com.ggd543.velocitydemo.App$.main(App.scala:20)
      at com.ggd543.velocitydemo.App.main(App.scala)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  
  Process finished with exit code 1
  </code></pre>