You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Carfield Yim <ca...@carfield.com.hk> on 2004/11/02 06:22:17 UTC
How to config velocity to use ClasspathResourceLoader?
Can anybody tell me how to setup VelocityEngine to use
ClasspathResourceLoader? I've the following code but fail to work:
VelocityEngine ve = new VelocityEngine();
ve.setProperty("resource.loader", "class");
ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Template t = ve.getTemplate(templatePath, "UTF-8");
t.merge(velocityContext, writer);
At "Template t = ve.getTemplate(templatePath, "UTF-8");", I get
NullPointerException, can anyone give me some hint about that?
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: How to config velocity to use ClasspathResourceLoader?
Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Carfield,
> Can anybody tell me how to setup VelocityEngine to use
> ClasspathResourceLoader?
http://jakarta.apache.org/velocity/api/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.html
> I've the following code but fail to work:
>
> VelocityEngine ve = new VelocityEngine();
> ve.setProperty("resource.loader", "class");
> ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
> Template t = ve.getTemplate(templatePath, "UTF-8");
> t.merge(velocityContext, writer);
>
> At "Template t = ve.getTemplate(templatePath, "UTF-8");", I get
> NullPointerException, can anyone give me some hint about that?
What does the stack trace have to say?
What was inside "templatePath"?
What was inside "velocityContext"?
Where is the classpath?
Where is the template? What does it look like?
Asking yourself these questions should lead you to the solution.
(Hopefully ;))
Best regards,
-- Shinobu Kawai
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org