Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-28-2010, 02:52 PM
Member
 
Join Date: Jan 2010
Posts: 16
Rep Power: 0
LovJava is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-28-2010, 05:45 PM
FON FON is offline
Senior Member
 
Join Date: Dec 2009
Location: Belgrade, Serbia
Posts: 292
Rep Power: 1
FON is on a distinguished road
Default
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

Code:
Hello $name!  Welcome to Velocity!

Code:
package velocity;

import java.io.File;
import java.io.FileReader;
import java.io.StringWriter;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;

public class HelloWorld
{
	public static void main( String[] args ) throws Exception
	{
		
		String path = "C:\\workspace\\Sve\\src\\velocity\\helloworld.vm";
		File f = new File(path);
		FileReader fr = new FileReader(f);
		
		int a = 0;
		
		while( (a = fr.read()) != -1 ){
			System.out.println(a);
		}
		
		/*  first, get and initialize an engine  */
		VelocityEngine ve = new VelocityEngine();
	
		ve.init();
		
		Template t = ve.getTemplate( "helloworld.vm" );
		
		System.out.println(ve.resourceExists("C:\\workspace\\Sve\\src\\velocity\\helloworld.vm"));
		/*  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!
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Velocity template file and output locations mjwoodford New To Java 1 10-05-2009 04:59 PM
Velocity Error trilochan New To Java 3 09-07-2009 03:28 PM
Apache Axis2 is built on Apache AXIOM, a new high performance, pull-based XML object. anusoniaa XML 0 11-15-2008 08:29 AM
Velocity / XML response sabatier XML 0 07-24-2007 02:13 PM
Velocity, cannot find resource sandor Web Frameworks 1 05-17-2007 11:58 PM


All times are GMT +2. The time now is 06:27 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org