Angelo Luis
Wed, 08 Nov 2006 02:25:58 -0800
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