Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java googleappengine上的velocity框架_Java_Google App Engine_Velocity - Fatal编程技术网

Java googleappengine上的velocity框架

Java googleappengine上的velocity框架,java,google-app-engine,velocity,Java,Google App Engine,Velocity,我正在尝试在谷歌应用程序引擎上使用velocity框架。我用main方法编写了一个小程序,并尝试在本地运行它。我得到以下例外情况: 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

我正在尝试在谷歌应用程序引擎上使用velocity框架。我用main方法编写了一个小程序,并尝试在本地运行它。我得到以下例外情况:

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
同样的程序在普通的eclipse项目上运行得非常好。有什么问题吗?

这可能不是世界末日,也不是故事的终结,但有一个与GAE兼容的软件列表:


我没有在里面找到速度。有可能人们只是忘记了测试并将其包括在列表中,但也有可能Velocity带来了一些与GAE不兼容的API。

似乎只是
ServletLogSleet
类需要
ServletContext
,Velocity本身可以完全独立于Servlet环境工作

由于您显然没有servelt日志,请在调用
ve.init()之前尝试添加以下内容:


…或。

速度可确定为在GAE/J上运行

使用Velocity作为模板引擎的框架在GAE/J上运行时没有问题


由于GAE/J是一个约束环境,它当然需要比平常更高的性能,但无论如何,它还是可以工作的。

谢谢carl。他们刚刚错过了它……它在app EngineGod上工作得非常好。您是否必须解决我读到的日志记录问题,或者您只是设法使其正常工作?事实上,我很想知道解决方案是什么,以供参考。
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() );    
 }
}
ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogChute");