Ich versuche Velocity-Framework auf Google App-Engine zu verwenden. Ich habe ein kleines Programm mit einer Hauptmethode geschrieben und versucht, es lokal auszuführen. Ich erhalte die folgende Ausnahme:Velocity-Framework auf Google App-Engine
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
Hier ist mein Programm:
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{
/* first, get and initialize an engine */
VelocityEngine ve = new VelocityEngine();
ve.init();
/* next, get the Template */
Template 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());
}
}
das gleiche Programm läuft auf einem normalen Eclipse-Projekt völlig in Ordnung. Was könnte das Problem sein?
danke carl..they hatte es gerade verpasst ... es funktioniert perfekt gut auf App-Engine – Aadith
Gut. Musstest du das Protokollierungsproblem lösen, über das ich gelesen habe, oder hast du es gerade geschafft, es so zu machen, wie es war? –
In der Tat würde mich interessieren, was die Lösung als Referenz war. –