Results 1 to 2 of 2
  1. #1
    LovJava is offline Member
    Join Date
    Jan 2010
    Rep Power

    Default org.apache.velocity.exception.ResourceNotFoundExce ption:

    Hi Everybody ,

    i am working with struts, spring and hibernate , while running the project i am getting org.apache.velocity.exception.ResourceNotFoundExce ption: exception . i have similar example with different requirement which is working fine.i've included all the jar files of velocity and even mentioned the tag lib in the web.xml , but i getting same error. please tell me if any body knows it.:mad:

  2. #2
    FON is offline Senior Member
    Join Date
    Dec 2009
    Belgrade, Serbia
    Rep Power


    Now this is really pain in the *

    After solving this i can help you setting up your properties for web project

    For a start take a look here:
    Nabble - Velocity - User - WebappResourceLoader: ResourceNotFoundException

    - -

    Same Velocity code won't work in diff projects
    and configuration is totally same ?!?

    Everyone is pointing to properties of Velocity Engine
    that has to be set manually like, before calling init():

    ve.setProperty("file.resource.loader.class",Classp athResourceLoader.class.getName());

    So my helloworld.vm resides in package called volocity
    next to HelloWorld class that uses it.

    Contenet of helloworld.vm is

    Java Code:
    Hello $name!  Welcome to Velocity!

    Java Code:
    package velocity;
    import org.apache.velocity.Template;
    import org.apache.velocity.VelocityContext;
    public class HelloWorld
    	public static void main( String[] args ) throws Exception
    		String path = "[B]C:\\workspace\\Sve\\src\\velocity\\helloworld.vm"[/B];
    		File f = new File(path);
    		FileReader fr = new FileReader(f);
    		int a = 0;
    		while( (a = != -1 ){
    		/*  first, get and initialize an engine  */
    		VelocityEngine ve = new VelocityEngine();
    		Template t = ve.getTemplate( [B]"helloworld.vm"[/B] );
    		/*  create a context and add data */
    		VelocityContext context = new VelocityContext();
    		context.put("name", "World");
    		/* now render the template into a StringWriter */
    		StringWriter writer = new StringWriter();
    		t.merge( context, writer );
    		/* show the World */
    		System.out.println( writer.toString() );     
    That code works in one project and won't work in other?!
    Both are standalone small projects, not much *.jars on classpath.
    I am using same velocity and commons jars in both and same
    system runtime. Using velocity-1.6.2.

    In debugger just after calling ve.init()
    35 properties are set (ve => _ri => configuration => Extended properties)
    Among them there are
    file.resource.loader.path and similar
    that probably has to be set to some other values in order to make this work

    good luck!

Similar Threads

  1. Apache Velocity template file and output locations
    By mjwoodford in forum New To Java
    Replies: 1
    Last Post: 10-05-2009, 03:59 PM
  2. Velocity Error
    By trilochan in forum New To Java
    Replies: 3
    Last Post: 09-07-2009, 02:28 PM
  3. Replies: 0
    Last Post: 11-15-2008, 08:29 AM
  4. Velocity / XML response
    By sabatier in forum XML
    Replies: 0
    Last Post: 07-24-2007, 01:13 PM
  5. Velocity, cannot find resource
    By sandor in forum Web Frameworks
    Replies: 1
    Last Post: 05-17-2007, 10:58 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