velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manjush G. Menon" <manj...@lycos.co.uk>
Subject Re: Problem merging template ResourceNotFoundException
Date Tue, 18 Nov 2003 03:46:24 GMT
Hi,

This is probably what you need:
Set the resource class loader in the properties object as below:

Properties properties = null;
if(properties == null){
properties = new Properties();
properties.put("resource.loader", "class");
properties.put("class.resource.loader.description","Template Class Loader");
properties.put("class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

VelocityEngine ve = new VelocityEngine();

//use it to initiate the Velocity Engine
ve.init(properties);

//Now this should work
template = ve.getTemplate("Template.vm");
context = new VelocityContext();
context.put("FNAME", "Manjush");
 ..........
StringWriter writer = new StringWriter();
template.merge(context, writer);

Hope this helps

--
Thanks
Manjush

----- Original Message -----
From: "kwirirai" <kwirirai@designat7.co.zw>
To: "Velocity Users List" <velocity-user@jakarta.apache.org>
Sent: Monday, November 17, 2003 2:26 PM
Subject: Re: Problem merging template ResourceNotFoundException


> In the same directory as the class file , I am using NetBeans to run the
> app.
>
> Geir Magnusson Jr. wrote:
>
> > Where are you putting the file?
> >
> > On Nov 16, 2003, at 3:18 AM, kwirirai wrote:
> >
> >> Hi guys
> >> I am having this problem when running the Example2 app :
> >> Problem merging template :
> >> org.apache.velocity.exception.ResourceNotFoundException: Unable to
> >> find resource 'example2.vm'
> >> I have tried adding the set the  resource loader property  to point
> >> to the correct directory , it still cannot find the file
> >> I have no more ideas on making it run,could you please help
> >>
> >> thanks
> >> kwiri
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>
> >>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message