You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Angelo Luis <an...@gmail.com> on 2006/11/07 18:57:58 UTC
:: LOAD A TEMPLATE FROM A EAR...
I'm trying to load a template from a EAR project... but i cannot undestand
why my tempalte is not load... i trying everything i kwon but with no
success
here is my code, the velocity.properties is in the war inside EAR e the
template in the ejb module in the package com.test:
velocity.propreties (in the war)
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
runtime.log.logsysten.class=org.apache.velocity.runtime.log.SimpleLog4JLogSystem
my code to retrive the template:
ServletContext servletContext =
((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext());
String file = servletContext.getRealPath("velocity/velocity.properties");
Properties properties = new Properties();
properties.load(new FileInputStream(file));
VelocityManager.init(properties);
Template t = VelocityManager.getTemplate("com/test/template.vm");
// create a context
Context context = ContextFactory.getInstance();
// populate with model data
ModelBean model = getModel();
context.put(model.getModelName(), model);
teh exception:
Caused by: org.apache.velocity.exception.ResourceNotFoundException: Unable
to find resource 'com/test/template.vm'
at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource
(ResourceManagerImpl.java:458)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(
ResourceManagerImpl.java:341)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(
RuntimeInstance.java:831)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(
RuntimeInstance.java:813)
at org.apache.velocity.app.VelocityEngine.getTemplate(
VelocityEngine.java:470)
at com.open.velocity.framework.VelocityManager.getTemplate(
VelocityManager.java:59)
at com.open.velocity.framework.AbstractVelocityContentTemplate.generate(
AbstractVelocityContentTemplate.java:32)
... 135 more
Re: :: LOAD A TEMPLATE FROM A EAR...
Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Angelo Luis" <an...@gmail.com> writes:
Hi,
what version of Velocity are you using? Could you please try one of
the 1.5 beta versions available from
http://people.apache.org/dist/jakarta/velocity/v1.5beta1/
We did a couple of fixes in the 1.5 cycle to better support EAR / J2EE
deployment so hopefully this should help you working things out.
Best regards
Henning
>------=_Part_7366_11934769.1162922278815
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>Content-Transfer-Encoding: 7bit
>Content-Disposition: inline
>I'm trying to load a template from a EAR project... but i cannot undestand
>why my tempalte is not load... i trying everything i kwon but with no
>success
>here is my code, the velocity.properties is in the war inside EAR e the
>template in the ejb module in the package com.test:
>velocity.propreties (in the war)
>resource.loader=class
>class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
>runtime.log.logsysten.class=org.apache.velocity.runtime.log.SimpleLog4JLogSystem
>my code to retrive the template:
>ServletContext servletContext =
>((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext());
>String file = servletContext.getRealPath("velocity/velocity.properties");
>Properties properties = new Properties();
>properties.load(new FileInputStream(file));
>VelocityManager.init(properties);
>Template t = VelocityManager.getTemplate("com/test/template.vm");
>// create a context
>Context context = ContextFactory.getInstance();
>// populate with model data
>ModelBean model = getModel();
>context.put(model.getModelName(), model);
>teh exception:
>Caused by: org.apache.velocity.exception.ResourceNotFoundException: Unable
>to find resource 'com/test/template.vm'
> at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource
>(ResourceManagerImpl.java:458)
> at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(
>ResourceManagerImpl.java:341)
> at org.apache.velocity.runtime.RuntimeInstance.getTemplate(
>RuntimeInstance.java:831)
> at org.apache.velocity.runtime.RuntimeInstance.getTemplate(
>RuntimeInstance.java:813)
> at org.apache.velocity.app.VelocityEngine.getTemplate(
>VelocityEngine.java:470)
> at com.open.velocity.framework.VelocityManager.getTemplate(
>VelocityManager.java:59)
> at com.open.velocity.framework.AbstractVelocityContentTemplate.generate(
>AbstractVelocityContentTemplate.java:32)
> ... 135 more
>------=_Part_7366_11934769.1162922278815--
--
Henning P. Schmiedehausen -- hps@intermeta.de | J2EE, Linux,
91054 Buckenhof, Germany -- +49 9131 506540 | Apache person
Open Source Consulting, Development, Design | Velocity - Turbine guy
"Save the cheerleader. Save the world."
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org