我正在尝试使用 Rythm template engine在 Google App Engine/Java 开发服务器 (GAE/J) 上。这是一个简单的安装,除了 Rythm 之外什么都没有添加到基本的 GAE devserver。
问题Rythm template engine and GAE没有完全回答我的问题(答案中指向的源代码给出了 404 错误)。
首先将以下代码添加到我的 servlet 代码中:
response.getWriter().println(Rythm.render("Successfully logged in as: @who",
user.getNickname()));
我得到:
java.security.AccessControlException: access denied ("java.io.FilePermission" "/var/folders/91/nv5sbz412b188nk22m644mq80000gn/T/__rythm" "read")
我认为发生这种情况是因为 Rythm 模板引擎试图查看 /var
以查看是否将 Rythm.render
的第一个参数视为文件名, GAE 抛出 AccessControlException
因为你不应该在 war 之外访问文件系统。
然后我在调用 Rythm.render
之前添加了以下几行(这些基本上是从 Rythm 的 HelloWorld example 复制和粘贴的):
// use Map to store the configuration
Map<String, Object> map = new HashMap<String, Object>();
// tell rythm where to find the template files
map.put("home.template", ".");
// init Rythm with our predefined configuration
Rythm.init(map);
仍然得到相同的异常。改变“。”将“/”作为 home.template
的值给出:
access denied ("java.io.FilePermission" "/Successfully logged in as: @who" "read")
当我尝试时:
map.put("home.template", this.getServletContext().getRealPath("/"));
我仍然遇到同样的异常。为什么 Rythm 会查看 /var/folders/91/nv5sbz412b188nk22m644mq80000gn/T/__rythm
?堆栈跟踪可在以下位置获得:https://drive.google.com/file/d/0B6dOUTDGuy2AWjR3Tmt2WTlkOUE/edit?usp=sharing (有没有更好的方法来共享堆栈跟踪?)
需要帮助!
以下是版本:
- GAE:1.8.7
- 专家:3.1.1
- 节奏:1.0-b11-SNAPSHOT
- 操作系统:OS X 10.9
最佳答案
您需要禁用 engine.file_write
配置以允许 Rythm 与 GAE 一起工作。在 http://rythmengine.org/doc/configuration.md#engine_file_write_enabled 上查看有关配置的更多信息
关于java - 节奏模板引擎与 GAE/J : AccessControlException in even simplest case,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20881565/