Results 1 to 2 of 2
  1. #1
    sandor is offline Member
    Join Date
    Apr 2007
    Rep Power

    Default Velocity, cannot find resource

    I have been fighting with Velocity for a day now. I think I have read every google page I found. Can anyone help?
    I am using this in a web app. I have a template just under the /web/ directory and it cannot find it. It shows the actual path when I print it to the console but alas I am stumped.
    Getting this error.
    org.apache.velocity.exception.ResourceNotFoundExce ption: Unable to find resource 'testTemplate.vm'
    Java Code:
    Properties p = new Properties();
     p.setProperty("resource.loader", "templateName");	
     p.setProperty( "file.resource.loader.path", "/web/");[COLOR="MediumTurquoise"]//I have tried a lot of things here in this line[/COLOR]
     VelocityContext context = new VelocityContext();
    template = Velocity.getTemplate(templateName);

  2. #2
    derrickD is offline Member
    Join Date
    Apr 2007
    Rep Power


    Try this:
    Java Code:
    p.setProperty( "resource.loader", "file" );
    p.setProperty("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.FileResourceLoader" );	
    The path would be the absolute path that you can get from the request.
    I am not sure if the order is important or not, but this has worked for me.
    It was not easy to finally figure out.

Similar Threads

  1. Reading a properties file using resource bundle.
    By rudrakanth in forum New To Java
    Replies: 1
    Last Post: 02-27-2009, 01:23 PM
  2. how to configure a JNDI URL resource
    By rinks in forum Advanced Java
    Replies: 0
    Last Post: 03-12-2008, 05:57 PM
  3. Replies: 0
    Last Post: 01-24-2008, 08:53 PM
  4. Setting the label of radio buttons from Resource bundle
    By rajeeshankar in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 12-17-2007, 10:23 AM
  5. Velocity / XML response
    By sabatier in forum XML
    Replies: 0
    Last Post: 07-24-2007, 02:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts