I think the problem is that your referecing your template by path and
not by it's place in the classpath.

Velocity.getTemplate("templates/description.vm");

should work.



MoritzGilsdorf wrote:
> Hi,
>
> I have that. Here is my code:
>
> props.setProperty(VelocityEngine.RESOURCE_LOADER, "classpath");
> props.setProperty("classpath." + VelocityEngine.RESOURCE_LOADER +
> ".class",ClasspathResourceLoader.class.getName());
> engine.init(props);
>
> Then I load my template with this:
>
> Template template =
> Velocity.getTemplate("src/main/resources/templates/description.vm");
>
> But this location is not in my .war file. Is there maybe something like the
> Path Annotation for Assets to get a reliable path?
>
> Moritz
>
>
>
> Angelo Chen wrote:
>   
>> Hi,
>>
>> here is what I did:
>>
>> store it under resources, then add:
>>   p.setProperty("resource.loader", "class");
>>  p.setProperty("class.resource.loader.class",
>> "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
>>  engine.init(p);
>>
>>
>> MoritzGilsdorf wrote:
>>     
>>> Hi,
>>>
>>> I'm trying to find a good place to store auxiliary files inside my
>>> project. I'm using velocity templates to generate simple text-files and
>>> in my development folder they are stored in
>>> CLASSPATH/src/main/resources/templates/.
>>>
>>> When I deploy my Project, the template directory is stored in my Projects
>>> .jar directly under templates and the app can't find them there.
>>>
>>> How can I store my templates so that find the with one command both in my
>>> dev-dir and in my deployed-dir? 
>>>
>>> Thanks,
>>>
>>> Moritz 
>>>
>>>
>>>       
>>     
>
>   

Reply via email to