velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pratibha shinagare <prabha...@yahoo.com>
Subject need Urgent Help
Date Wed, 30 Aug 2006 05:05:08 GMT
Hi
  I m pratibha
  I m using Velocity.
  In my debian machin i m having JBoss-Eclipse ide,
  JBoss server, I installed velocity ide plugin for   
       Eclipse(plugins/org.apache.velocity_1.3.1)
  i m trying simple velocity application.
  i m getting following error- 

java.lang.NullPointerException
	at
org.apache.velocity.runtime.RuntimeInstance.setDefaultProperties(RuntimeInstance.java:295)
	at
org.apache.velocity.runtime.RuntimeInstance.initializeProperties(RuntimeInstance.java:423)
	at
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:266)
	at
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:441)
	at
org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:148)
	at hello.HelloWorld.main(HelloWorld.java:34)

My
 Two files are-
  HellowWorld.java
package hello;

import java.io.StringWriter;
import java.util.Properties;
//import java.io.*;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
//import org.apache.velocity.runtime.parser.*;

//import org.apache.velocity.exception.*;

/**
 *  Simple program to demonstrate the basic 
 *  technique of rendering a Velocity template
 */
public class HelloWorld
{
    public static void main( String[] args )
        
    {
        /*
         *  first, get and initialize a Velocity
engine
         */
         
        
        try{
        	
           VelocityEngine ve = new VelocityEngine();
           Properties p = new Properties();
           p.setProperty("file.resource.loader.path",
"/root/workspace/Test/hello");
           //Velocity.init( p );
        	     	
           ve.init(p);

        /*
         *  next, get the Template  
         */
        Template t =null;
        
        t = ve.getTemplate( "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() );  
        }catch(java.lang.Exception le)
           {le.printStackTrace();}
         /*catch(Exception e)
         { e.printStackTrace();}*/
         
    }
}

and
HelloWorld.vm

code
Hello $name!  Welcome to Velocity!

Please reply

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message