On Wed, Mar 5, 2008 at 8:03 AM, cleverpig <[EMAIL PROTECTED]> wrote: > 1.I put template file in template directory which under > classpath:templates\people.vm,by the way,I use Eclipse to develope > these. > 2.put velocity.properties under classpath: > resource.loader = file
I do it like this: public class VelocityRepresentation extends TemplateRepresentation { private static final String templateDir = "templates/"; public VelocityRepresentation(String templateName, Map<String, Object> dataModel, MediaType mediaType) { super(templateDir + templateName, dataModel, mediaType); configureEngine(); } public VelocityRepresentation(String templateName, MediaType mediaType) { super(templateDir + templateName, mediaType); configureEngine(); } protected void configureEngine() { VelocityEngine engine = getEngine(); engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "class"); engine.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); } } And have a directory "templates" in the classpath. This works fine even when deployed on a Tomcat installation. However I believe as Jerome says that this should have been configured by the application instead of for each representation. For instance I have problems when configuring velocity logging in this place that I end up with duplicate logging.. -- Stian Soiland-Reyes, myGrid team School of Computer Science The University of Manchester http://www.cs.man.ac.uk/~ssoiland/