I am trying to use the Rythm template engine on Google App Engine/Java devserver (GAE/J). This is a bare-bones install with nothing but Rythm added to the base GAE devserver.
The question Rythm template engine and GAE doesn't quite answer my question (the source code pointed to in the answer gives a 404 error).
Started by adding the following code to my servlet code:
response.getWriter().println(Rythm.render("Successfully logged in as: @who",
user.getNickname()));
and I get:
java.security.AccessControlException: access denied ("java.io.FilePermission" "/var/folders/91/nv5sbz412b188nk22m644mq80000gn/T/__rythm" "read")
I thought this is happening because the Rythm template engine tries to look in /var
to see whether to treat first parameter to Rythm.render
as a filename or not, and GAE throws the AccessControlException
because you're not supposed to access the filesystem outside of the war.
I then added the following lines before the call to Rythm.render
(these are essentially copy-and-pasted from Rythm's 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);
Still get that same exception. Changing the "." to "/" as value for home.template
gives:
access denied ("java.io.FilePermission" "/Successfully logged in as: @who" "read")
When I tried:
map.put("home.template", this.getServletContext().getRealPath("/"));
I still get the same exception. Why is Rythm looking at /var/folders/91/nv5sbz412b188nk22m644mq80000gn/T/__rythm
at all? Stack trace is available at: https://drive.google.com/file/d/0B6dOUTDGuy2AWjR3Tmt2WTlkOUE/edit?usp=sharing (is there a better way to share a stack trace?)
Need help!
Here are the versions:
- GAE: 1.8.7
- Maven: 3.1.1
- Rythm: 1.0-b11-SNAPSHOT
- OS: OS X 10.9
You need to disable
engine.file_write
configuration to allow Rythm be working with GAE. Check more about the configuration on http://rythmengine.org/doc/configuration.md#engine_file_write_enabled