Hello Leo, For starters, try and initialize velocity with a Properties object loaded using a Resource. Make sure that velocity.properties is in the classpath.
e.g. ------------------------ InputStream vProps = this.getClass().getResourceAsStream("/velocity.properties"); try { Properties properties = new Properties(); properties.load(vProps); VelocityEngine velocityEngine = new VelocityEngine(); velocityEngine.init(properties); VelocityContext context = new VelocityContext(); } catch(Exception e) { logger.error("velocity engine failed to initialise", e); } ------------------------ Also, in velocity.properties you have to specify the template loader to use. (have a look here for template loaders, http://jakarta.apache.org/velocity/developer-guide.html#Configuring%20Resource%20Loaders) Try ClasspathLoader ---------------------- resource.loader = production production.loader.description = "Production Resource Loader" production.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader ---------------------- When using velocityEngine.getTemplate(String) just make sure that the path is in the following format -------------------- templates/myTemplate.vm -------------------- and that "templates/" dir is in the classpath since you are using a ClasspathResourceLoader Regards, Markos On Tuesday 28 June 2005 09:06, Leo Asanov wrote: > Hi! > > What is the right way to initialize Velocity outside > of a servlet? My application works fine when I'm using > VelocityViewServlet, but when I'm trying to initialize > Velocity from any standard Java class (with > Velocity.init(absolutePathToPropertiesFile)) > Velocity.mergeTemplate always throws > "ResourceNotFound" exception. > > I guess this happens because Velocity cannot get > parent directory of a web application without a > reference to servlet context. But I'm not sure what I > can do with this. I can't specify absolute path in > velocity.properties and I would prefer to avoid > setting path properties directly in the code (I don't > know how to it anyway - tried > Velocity.setProperty("file.resource.loader.path",absolutePathToTemplateDire >ctory) and it didn't work). > Maybe it's possible to pass a "default directory" path > somehow? > > Cheers, > Leo Asanov > > > > ____________________________________________________ > Yahoo! Sports > Rekindle the Rivalries. Sign up for Fantasy Football > http://football.fantasysports.yahoo.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]