title: Getting Error Resource Not Found Exception while using velocity
body: <p>Not able to attach the template for sending the mail..</p>
  
  <p>-servlet.xml</p>
  
  <pre><code>&lt;bean id="velocityEngine" 
      class="org.springframework.ui.velocity.VelocityEngineFactoryBean"&gt;
          &lt;property name="velocityProperties"&gt;
               &lt;value&gt;
                resource.loader=class
                class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
               &lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="velocityConfig"
          class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"&gt;
  
          &lt;property name="resourceLoaderPath" value="/"/&gt;
  
  &lt;/bean&gt;
  
      &lt;bean id="velocityviewResolver"
            class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"
            p:prefix="/WEB-INF/velocity/"
            p:suffix=".vm" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>code :
  The error is pointing to this line which i am using in my Service implementation</p>
  
  <pre><code>String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mailtemplate", model);
  </code></pre>
  
  <p>I am getting an error saying not able to find any resource </p>
  
  <p>The complete stack trace of error is:</p>
  
  <pre><code>org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'mailtemplate'
      at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:483)
      at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:354)
      at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1400)
      at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:370)
      at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:345)
      at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplate(VelocityEngineUtils.java:58)
      at org.springframework.ui.velocity.VelocityEngineUtils.mergeTemplateIntoString(VelocityEngineUtils.java:122)
      at service.impl.EmployeeServiceImpl.sendMail(EmployeeServiceImpl.java:110)
      at controllers.TrainingInvitationController.sendMail(TrainingInvitationController.java:54)
      at controllers.TrainingInvitationController$$FastClassByCGLIB$$176c7e66.invoke()
      at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
      at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
      at controllers.TrainingInvitationController$$EnhancerByCGLIB$$b58c7689.sendMail()
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:421)
      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:136)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:326)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:313)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:445)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:356)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:226)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:627)
      at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:149)
      at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:123)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:141)
      at org.mortbay.jetty.Server.handle(Server.java:269)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:430)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:701)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:617)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:199)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:339)
      at org.mortbay.jetty.nio.HttpChannelEndPoint.run(HttpChannelEndPoint.java:270)
      at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
  </code></pre>
  
  <p>Now how to resolve this problem?</p>