I am trying to use the speed environment in the google engine. I wrote a small program with the main method and tried to run it locally. I get the following exception:
Exception in thread "main" org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.ServletLogChute with the current runtime configuration.
at org.apache.velocity.runtime.log.LogManager.createLogChute (LogManager.java:206)
at org.apache.velocity.runtime.log.LogManager.updateLog (LogManager.java:255)
at org.apache.velocity.runtime.RuntimeInstance.initializeLog (RuntimeInstance.java:795)
at org.apache.velocity.runtime.RuntimeInstance.init (RuntimeInstance.java:250)
at org.apache.velocity.app.VelocityEngine.init (VelocityEngine.java:107)
at Main.main (Main.java:10)
Caused by: java.lang.UnsupportedOperationException: Could not retrieve ServletContext from application attributes
at org.apache.velocity.runtime.log.ServletLogChute.init (ServletLogChute.java:73)
at org.apache.velocity.runtime.log.LogManager.createLogChute (LogManager.java:157)
... 5 more
Here is my program:
import java.io.StringWriter;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
public class Main {
public static void main(String[] args) throws Exception{
VelocityEngine ve = new VelocityEngine();
ve.init();
Template t = ve.getTemplate( "helloworld.vm" );
VelocityContext context = new VelocityContext();
context.put("name", "World");
StringWriter writer = new StringWriter();
t.merge( context, writer );
System.out.println( writer.toString() );
}
}
the same program works fine in a regular eclipse project. what could be the problem?
source
share