You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by MoritzGilsdorf <ma...@moritz-gilsdorf.de> on 2008/02/21 20:18:02 UTC
T5: Using resources
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
--
View this message in context: http://www.nabble.com/T5%3A-Using-resources-tp15618690p15618690.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Using resources
Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi,
my deployment is also packaged into jar file under WEB-INF/lib, except i
don't have the templates directory, in my case the *.vm files are in the
place where log4j.properties is, try to move those *.vm files into that
place and see if velocity can find it.
a.c.
MoritzGilsdorf wrote:
>
> Then I get:
>
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource 'description.vm'
>
> Obviously Velocity can't find the template because in my deployment it is
> packaged in the jar file under WEB-INF/lib .
>
>
> Angelo Chen wrote:
>>
>> how about just :
>>
>> emplate template = Velocity.getTemplate("description.vm");
>>
>>
>> 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
>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/T5%3A-Using-resources-tp15618690p15630128.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Using resources
Posted by MoritzGilsdorf <ma...@moritz-gilsdorf.de>.
Then I get:
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'description.vm'
Obviously Velocity can't find the template because in my deployment it is
packaged in the jar file under WEB-INF/lib .
Angelo Chen wrote:
>
> how about just :
>
> emplate template = Velocity.getTemplate("description.vm");
>
>
> 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
>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/T5%3A-Using-resources-tp15618690p15629960.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Using resources
Posted by Angelo Chen <an...@yahoo.com.hk>.
how about just :
emplate template = Velocity.getTemplate("description.vm");
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
>
>
>
--
View this message in context: http://www.nabble.com/T5%3A-Using-resources-tp15618690p15629666.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Using resources
Posted by Hugo Palma <hu...@gmail.com>.
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
>>>
>>>
>>>
>>
>
>
Re: T5: Using resources
Posted by MoritzGilsdorf <ma...@moritz-gilsdorf.de>.
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
>>
>>
>
>
--
View this message in context: http://www.nabble.com/T5%3A-Using-resources-tp15618690p15629016.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Using resources
Posted by Angelo Chen <an...@yahoo.com.hk>.
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
>
>
--
View this message in context: http://www.nabble.com/T5%3A-Using-resources-tp15618690p15628784.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org